[英]Issue adding Excel autofilter in openpyxl program
你應該用熊貓
import pandas as pd
df = pd.read_excel('./Main.xlsx') #./ means, Main.xlsx is in same folder with code.py
#I think first column name is Country
df_india = df[df['Country']=='India']
df_japan = df[df['Country']=='Japan']
frames = [df_india , df_japan]
main_df = pd.concat(frames)
main_df = main_df.reset_index(drop = True)
writer = pd.ExcelWriter('results.xlsx', engine='xlsxwriter')
main_df.to_excel(writer, sheet_name='Sheet1')
有關更多信息,請檢查https://pandas.pydata.org/pandas-docs/stable/genic/pandas.DataFrame.to_excel.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.