![](/img/trans.png)
[英]pandas dataframe to existing excel worksheet and wrap column text with openpyxl
[英]append data frame to existing worksheet for particular column by pandas or openpy excel
首先使用pd.read_excel(file path)
读取 excel 文件,然后使用:
df.append(df2)
插图:
df = pd.DataFrame({'code':[1,2], 'name': ['a', 'b'], 'class':[5,9], 'rol': ['y', 'h'], 'sub':['eng', 'math']})
df2 = pd.DataFrame({'name': ['c', 'd'], 'class':[5,9], 'rol': ['y', 'h']})
df.append(df2)
输出:
code name class rol sub
0 1.0 a 5 y eng
1 2.0 b 9 h math
0 NaN c 5 y NaN
1 NaN d 9 h NaN
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.