Skip to content

Strange behavior of Series/TimeSeries with datetime index #758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
soramame0518 opened this issue Feb 7, 2012 · 4 comments
Closed

Strange behavior of Series/TimeSeries with datetime index #758

soramame0518 opened this issue Feb 7, 2012 · 4 comments
Labels
Milestone

Comments

@soramame0518
Copy link

I had a trouble with Series and TimeSeries using datetime index. Here is an example:

In [1]: from pandas import *

In [2]: t = [datetime(2012, 2, 7, 0, 0, 0), datetime(2012, 2, 7, 23, 0, 0)]

In [3]: s = Series([0, 1], index=t)

In [4]: print s
2012-02-07 0
2012-02-07 00:00:00 1

The first index value should be '2012-02-07 00:00:00', and the second should be '2012-02-07 23:00:00' Am I doing wrong?

@adamklein
Copy link
Contributor

Confirmed, it looks like an output or formatting error. It also looks like the data should be ok.

In [5]: t
Out[5]: [datetime.datetime(2012, 2, 7, 0, 0), datetime.datetime(2012, 2, 7, 23, 0)]

In [6]: s = Series([0,1], index=t)

In [7]: s
Out[7]: 
2012-02-07             0
2012-02-07 00:00:00    1

In [9]: s.index
Out[9]: Index([2012-02-07 00:00:00, 2012-02-07 23:00:00], dtype=object)

In [10]: s.index[0]
Out[10]: datetime.datetime(2012, 2, 7, 0, 0)

In [11]: s.index[1]
Out[11]: datetime.datetime(2012, 2, 7, 23, 0)

@soramame0518
Copy link
Author

Thanks for your comment!

@wesm wesm closed this as completed in 4f793be Feb 7, 2012
@wesm
Copy link
Member

wesm commented Feb 7, 2012

thanks for reporting, fixed the underlying issue, now looks like

In [1]: t = [datetime(2012, 2, 7, 0, 0, 0), datetime(2012, 2, 7, 23, 0, 0)]

In [2]: 

In [2]: s = Series([0, 1], index=t)

In [3]: s
Out[3]: 
2012-02-07 00:00:00    0
2012-02-07 23:00:00    1

@soramame0518
Copy link
Author

Thanks a lot!

dan-nadler pushed a commit to dan-nadler/pandas that referenced this issue Sep 23, 2019
Roll forward setup.py to 1.76 and update CHANGES.md with fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants