Read excel sheet

import pandas as pd
import numpy as np
from datetime import date
today=date.today()
downpath='/Users/kangyongqing/Downloads/'

file_dangan='20230726_095440.csv'
file_banke='我的趣味中国之旅C12023-07-26.xlsx'


dt1=pd.read_csv(downpath+file_dangan)
# print(dt1.columns)
# print(dt1.loc[dt1['教师姓名']=='武月园'].T)
dt2=pd.read_excel(downpath+file_banke,engine='openpyxl')
for sheet_name,df in dt2.items():
    print(sheet_name)
    print(df.head())

pd.read_excel(filepath,engine='openpyxl') reads sheet_name=0 by default, and the effect of not filling in and filling in sheet_name=0 is the same;

items will display the column names and data details of each column;

sheet_name=None, all sheets are imported, and the items method will display the sheet name and data examples of each sheet;

sheet_name=['', ''] can import multiple sheets, but only one input will import multiple sheets by default

Guess you like

Origin blog.csdn.net/Darin2017/article/details/131958533