import pandas as pd from numpy import * df = pd.read_excel('C:\\Users\\Administrator\\PycharmProjects\\untitled\\python文件包\\python与数据科学\\excel-comp-data.xlsx') df.head() m,n = shape(df) #m为行数,n为列数 #增加新列total_all df['total_all'] = pd.Series('',index = df.index) #对其赋值 df['total_all'] = df['Jan']+df['Feb']+df['Mar'] #对列的名字大写化 df.columns = [c.upper() for c in df.columns] #找出大于jan列100000的项 df[df['JAN']>100000] #计算所有的和 df.loc[df.index[-1],'TOTAL_ALL']=sum(df['TOTAL_ALL'][:-2])
简单处理xlsx文件,简单修改即可轻松处理其他格式文件
最新推荐文章于 2023-05-25 18:46:26 发布