📜  创建excel文件python代码示例

📅  最后修改于: 2022-03-11 14:46:02.937000             🧑  作者: Mango

代码示例1
#import openpyxl  # Must be as least installed, import is optional
import pandas as pd
import numpy as np
# Create dataframe with your data; 
df = pd.DataFrame(np.array([[23, 99, 78], [65, 95, 90], [90, 98, 96]]), columns=['Bob', 'Dilan', 'Live'])
df
   Bob  Dilan  Live
0   23     99    78
1   65     95    90
2   90     98    96
# Export the dataframe as Excel File
# sheet_name="Your Sheet Name" is optionnal
df.to_excel(r'C:\Users\Ron\Desktop\File_Name.xlsx', sheet_name="Your Sheet Name" ,index = False)