举个例子:
import pandas as pd
def multiple_dfs(sheet, row=0):
writer = pd.ExcelWriter("testing.xlsx", engine='openpyxl')
df1 = pd.DataFrame(['Title'])
df2 = pd.DataFrame({'user': ['Bob', 'Jane', 'Alice', 'Robert', 'John', 'Joe', 'Jordan'],
'income': [40000, 50000, 42000, 25000, 2000000, 12000, 32000]})
df1.to_excel(writer, sheet, startrow=row, header=None, \
index=False)
df2.to_excel(writer, sheet, startrow=row+2, index=False)
writer.save()
writer.close()
style_dfs(df1)
multiple_dfs('aaa')
对于dfs
,我想将Excel行数限制为5.
是否可以用熊猫做这样的事情?