python之数据分析pandas (二)
import pandas as pd #此包在pandas基础上实现sql from pandasql import sqldf file_name=r'/Users/gaochengcheng/Desktop/center.xls' file_name3='/Users/gaochengcheng/Desktop/center_left3.xls' file_name4='/Users/gaochengcheng/Desktop/center_left4.xls' #读数据 df = pd.read_excel(file_name, sheet_name = "left3") # 打印表数据,如果数据太多,会略去中间部分 print(df) sql ='''select * from df ''' df2=sqldf(sql) print(df2) #写数据 df2.to_excel(file_name4,index=False,header=True)