您的位置:首页 > 编程语言 > Python开发

python.pandas read and write CSV file

2017-07-25 16:27 615 查看
#read and write csv of pandas
import pandas as pd

goog =pd.read_csv(r'C:\python\demo\LiaoXueFeng\data\test_vrt.csv',index_col=0)
goog=goog.reindex(pd.to_datetime(goog.index))
print(goog.head())
print(goog.tail())

data2 = [{'july': 9999, 'han': 5000, 'zewei': 1000}, {'july': 9999, 'han': 5000, 'zewei': 1000},
{'july': 9999, 'han': 5000, 'zewe2i': 1000}]
df3 = pd.DataFrame(data2)
df3.to_csv(r'C:\python\demo\LiaoXueFeng\data\goog2.csv',encoding='GBK',mode='a')
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: