Skip to content
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

the latest version of pd.Timestamp issue on transforming timestamp #22498

Closed
foolcage opened this issue Aug 24, 2018 · 3 comments
Closed

the latest version of pd.Timestamp issue on transforming timestamp #22498

foolcage opened this issue Aug 24, 2018 · 3 comments
Labels
Duplicate Report Duplicate issue or pull request

Comments

@foolcage
Copy link

In [1]: import pandas as pd

In [2]: pd.Timestamp.fromtimestamp(1535097720.0).timestamp()
Out[2]: 1535126520.0

the input is:1535097720.0 and the output is:1535126520.0

It seems pd.Timestamp use the local time zone to format the time and then treat it as UTC+0,but it's wrong.

in version 0.21.0, it works:

In [56]: pd.Timestamp.fromtimestamp(1535097720.0).timestamp()
Out[56]: 1535097720.0

@hanke0
Copy link

hanke0 commented Aug 24, 2018

It's like pandas will automatic set timezone to your local timezone. In my location, this behave like:

In [5]: pd.Timestamp.fromtimestamp(0).timestamp()
Out[5]: 28800.0

28800 = 8 * 60 * 60, which means UTC+8. So you should do:

In [8]: pd.Timestamp.utcfromtimestamp(0).timestamp()
Out[8]: 0.0

Hoo, it works!

@foolcage
Copy link
Author

foolcage commented Aug 24, 2018

@ko-han I think this is confused,timestamp should not related with timezone.

It is just:

the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC) Thursday, 1 January 1970

So we could compare the timestamp in different timezone.

And I think the behavior is right in 0.21.0

@jbrockmendel
Copy link
Member

Duplicate of #22450.

@chris-b1 chris-b1 added the Duplicate Report Duplicate issue or pull request label Aug 24, 2018
@chris-b1 chris-b1 added this to the No action milestone Aug 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

4 participants