pip install xlrd
pip install xlwt
pip install xlutils
pip install xlwings
pip install XlsxWriter
pip install openpyxl
pip install pandas
pip install pandasql
import DrawSquare import Decorators import xlrd import xlwt import xlwings as xw import xlsxwriter import openpyxl import pandas as pd import pandasql def print_hi(name): # Use a breakpoint in the code line below to debug your script. print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint. # Press the green button in the gutter to run the script. if __name__ == '__main__': print_hi('PyCharm,geovin du study') #skiprows=1 跳过第1行 xlspath = r'C:\Users\geovindu\PycharmProjects\pythonProject1\2月.xls' xlsxpath = r'C:\Users\geovindu\PycharmProjects\pythonProject1\2月.xlsx' xlspath1 = r'C:\Users\geovindu\PycharmProjects\pythonProject1\2月0.xls' xlsxpath1 = r'C:\Users\geovindu\PycharmProjects\pythonProject1\2月0.xlsx' xls = pd.read_excel(io=xlspath, sheet_name='Sheet1',index_col=(0,1)) # xlsx = pd.read_excel(io=xlsxpath, sheet_name='Sheet1',index_col=(0,1)) # print(xls.head()) #xls.info() print(xlsx.head()) #xlsx.info() print(xlsx.columns) print(xlsx.index) duxls = pd.read_excel(io=xlspath, sheet_name='Sheet1', names=["社保明细","1月缴纳明细(元)"]) # print(duxls.head()) xls1 = pd.read_excel(io=xlspath1, sheet_name='Sheet1',index_col=(2,3),skiprows=1) #从第2列至第3列,省略第一行 xlsx1 = pd.read_excel(io=xlsxpath1, sheet_name='Sheet1',index_col=(2,3),skiprows=1) #从第2列至第3列,省略第一行 print(xls1.head()) print(xlsx1.head()) print(xls1.columns.names) for a in xls1.columns.names: print("name:",a) print(xlsx1.columns) print(xls1.index) print(xlsx1.index) xls1.fillna(value="No Data Found", inplace=True) xlsx1.fillna(value="No Data Found", inplace=True) print(xlsx1) print(xls1) for data in xlsx1.describe(): print("d:",data) print(xlsx1.groupby(['社保明细',"1月缴纳明细(元)"]).sum()) two=xls1.merge(xlsx1, how='left',on=['社保明细',"1月缴纳明细(元)"]) print(two)
标签:name,python,excel,read,install,print,import,xlsx1,xls1 From: https://www.cnblogs.com/geovindu/p/17476219.html