pandas:DataFrname
一
https://www.cnblogs.com/YingLai/p/9291768.html
cd 到csv文件目录下 df = pd.read_csv('fiename.csv') # 读取csv文件方式一 # 读取csv文件方式er df = open('filename.csv') df.read() #写入文件 df.to_csv("newfilename.csv")
二
https://www.cnblogs.com/YingLai/p/9300775.html
import requests import json import pandas as pd class Write_to_excel(): def get_data(self,url): response=requests.get(url).content data=json.loads(response) return data['data'] def write_csv(self,filename): df.to_csv(filename) def read_csv(self,filename): df_read=pd.read_csv(filename) # 读取csv文件方式一 # 读取csv文件方式er # df = open('filename.csv') # df.read() return df_read if __name__ == '__main__': url=r'http://10.99.3.21/tp/zsfnd/gettabledata?table=db_zndt.tb_ip_invest' tt=Write_to_excel() data=tt.get_data(url) # # for i in data: # # print(i) df=pd.DataFrame(data) print(df.shape) gina=df.describe() # 获取快速统计 # #更改字段名 # df=df.rename(columns={'index_period_type':'index_period_gina'}) # # # df.rename(columns={'旧的列名': '新的列名'}) # print(df) # print(gina,type(gina)) # print(df.to_dict('records'))#将dataframe 转换成字典 filename = r'E:\转换开发2021\newfilename.csv' # tt.write_csv(filename) dd=tt.read_csv(filename) dd=dd.to_dict('records') for i in dd: print(i)
三
https://www.cnblogs.com/YingLai/p/9302739.html 学习