[英]pandas datetime to index bug OR possible time travel discovery
Is this a bug? 这是错误吗? It looks like pushing a datetime object into a dataframe, then indexing on the datetime column, does some scrambling of the date but produces no error (see line 97).
看起来像将datetime对象推入数据帧,然后在datetime列上建立索引,对日期进行一些加扰,但不会产生任何错误(请参见第97行)。 Interestingly the view looks right so I'm guessing it's some sort of memory indexing thing.
有趣的是,该视图看起来正确,因此我猜测这是某种形式的内存索引。
This was on a fairly recent build of pandas: pandas-0.9.1.dev_85d982d-py2.7-linux-x86_64.egg. 这是在最近的熊猫版本上建立的:pandas-0.9.1.dev_85d982d-py2.7-linux-x86_64.egg。
In [93]: import datetime, pandas
In [94]: df = pandas.DataFrame([[datetime.datetime.today(), 12.1]], columns=['Date', 'Value'])
In [95]: df = df.set_index('Date')
In [96]: df
Out[96]:
Value
Date
2012-11-22 12:12:40.905739 12.1
In [97]: df.index
Out[97]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2190-12-31 02:18:44.941732032]
Length: 1, Freq: None, Timezone: None
In [98]: df = df.reset_index()
In [99]: df
Out[99]:
Date Value
0 2190-12-31 02:18:44.941732032 12.1
Updating to a newer version of numpy (and rebuilding pandas) seems to have fixed the problem. 更新到较新版本的numpy(并重建熊猫)似乎已经解决了该问题。
numpy.
麻木 version '1.8.0.dev-fd78546' pandas.
版本 “ 1.8.0.dev-fd78546”。 version '0.9.1.dev-85d982d'
版本 '0.9.1.dev-85d982d'
I posted and closed the issue here: https://github.com/pydata/pandas/issues/2329 我在这里发布并关闭了该问题: https : //github.com/pydata/pandas/issues/2329
Feel free to close this question on stackoverflow if you think it is superfluous, though who knows maybe someone else will run into it too. 如果您认为它是多余的,可以随时在stackoverflow上关闭此问题,尽管谁知道也许其他人也会遇到它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.