使用python完成对excel的操作
import numpy as np import pandas as pd 1.通过外部文件导入数据表 df=pd.DataFrame(pd.read_csv('name.csv',header=1)) df=pd.DataFrame(pd.read_Excel('name.xlsx')) 2.通过填入数据生成数据表 df = pd.DataFrame({"id":[1001,1002,1003,1004,1005,1006], "date":pd.date_range('20130102', periods=6), "city":['Beijing ', 'SH', ' guangzhou ', 'Shen zhen', 'shanghai', 'BEIJING '], "age":[23,44,54,32,34,32], "category":['100-A','100-B','110-A','110-C','2 10-A','130-F'], "price":[1200,np.nan,2133,5433,np.nan,4432]}, columns =['id','date','city','category','age', 'price']) 3.检查数据表的维度:shape属性 df.shape 结果输出 (6,6) 4.查看数据表信息 df.info() 5