dta_h is is a DataFrame and dta_h.Datetime looks like this:
0 2013-03-01 00:00:00
1 2013-02-28 23:00:00
2 2013-02-28 22:00:00
3 2013-02-28 21:00:00
...
Name: Datetime, Length: 63001, dtype: datetime64[ns]
Until recently (I'll explain later what this means) I could do this to subtract one hours of each time period:
dta_h.Datetime-np.timedelta(hours=1)
But now, if I do the above, I am getting this:
0 2013-03-01 00:11:34.967296
1 2013-02-28 23:11:34.967296
2 2013-02-28 22:11:34.967296
3 2013-02-28 21:11:34.967296
...
Which clearly is not what I want. However, this:
[i-timedelta(hours=1) for i in dta_h.Datetime ]
still yields the desirted result:
0 2013-02-28 23:00:00
1 2013-02-28 22:00:00
2 2013-02-28 21:00:00
3 2013-02-28 20:00:00
....
Length: 63001, dtype: datetime64[ns]
I am 99% sure that this problem started when I upgraded to Pandas 0.11. I have been looking around in the documentation for any difference in the version that might explain it without success. I also found this posting:
pandas handling of numpy timedelta64[ms]
which refers to this Pandas issue
https://github.com/pydata/pandas/issues/3009
Based on what I read there, I tried:
dta_h.Datetime-np.timedelta64(hours=1)
But this actually does nothing:
0 2013-03-01 00:00:00
1 2013-02-28 23:00:00
2 2013-02-28 22:00:00
3 2013-02-28 21:00:00
...
Any idea why 1) the df-np.timedelta stopped working, and 2) why the comprehension list version still works? Thanks for you help.
FYI, I am using Numpy 1.6.2 and, a I said earlier, recently upgraded from Pandas 0.9 to 0.11