【发布时间】:2017-08-01 21:30:36
【问题描述】:
我有一个表格,其中日期和时间以year:day_of_year:seconds_of_day(第二列)的格式给出。可以在here找到一个示例文件
ABCD 15:010:00000 2564.6 4.0 -0.380 0.417 -1.313 0.520
ABCD 15:010:00300 2564.3 3.7 -0.389 0.396 -1.318 0.503
ABCD 15:010:00600 2563.9 3.5 -0.397 0.389 -1.324 0.496
ABCD 15:010:00900 2563.9 3.3 -0.411 0.368 -1.322 0.476
ABCD 15:010:01200 2563.8 3.0 -0.425 0.361 -1.320 0.466
ABCD 15:010:01500 2563.9 2.8 -0.432 0.340 -1.312 0.447
ABCD 15:010:01800 2564.3 2.6 -0.439 0.334 -1.304 0.439
我用pandas包把上面的表格放在pandas.DataFrame:
names=['Site', 'Epoch', 'TroTot', 'Stdev','TgnTot', 'TgnStd', 'TgeTot', 'TgeStd']
parser = lambda x: pd.datetime.strptime(x, '%y:%j:%???')
df = pd.read_csv([FILE][1],
header=None,
names=names,
delim_whitespace=True,
parse_dates=['Epoch'],
date_parser=parser)
我查看了文档,但在我看来,一天中的秒数没有格式。我怎样才能改变解析器函数以在这种格式下正常工作?
【问题讨论】:
标签: python csv pandas datetime