【发布时间】:2017-12-12 20:01:09
【问题描述】:
我有以下代码:
#!/usr/bin/python
import pandas as pd
df = pd.read_excel(io='http://www.iea.org/gtf/download/Export_GTF_IEA.xls', sheetname='Data', skip_footer=5, )
df = df.drop('Unnamed: 2', axis=1)
df = df.drop('Exit', axis=1)
df = df.drop('Entry', axis=1)
df = df.drop('MAXFLOW (Mm3/h)', axis=1)
df = df.T
df.to_csv('foo.csv', encoding='utf-8', sep='\t', header=False)
#
输出示例如下所示:
print df
0 1 2 3 4 \
Borderpoint Adriatic LNG Almeria Alveringem Alveringem Badajoz
2008-10-01 00:00:00 0 0 0 0 152.81
2008-11-01 00:00:00 0 0 0 0 183.31
2008-12-01 00:00:00 0 0 0 0 85.21
2009-01-01 00:00:00 0 0 0 0 199.16
2009-02-01 00:00:00 0 0 0 0 104.48
2009-03-01 00:00:00 0 0 0 0 9.17
如何将时间戳转换为月末日期?
【问题讨论】:
-
在您的示例输出中,
Borderpoint列日期是每个月的第一个日期(不是最后一个)。你要哪个?
标签: python pandas date timestamp date-formatting