Skip to content

Add timestamp method+test; closes #17329 #17906

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

Merged
merged 17 commits into from
Oct 27, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix timestamp test
  • Loading branch information
jbrockmendel committed Oct 20, 2017
commit 715b74024fbfaca182eb1869ac816f87e4ef4b81
2 changes: 1 addition & 1 deletion pandas/tests/scalar/test_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ def test_timestamp(self):

if PY3:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this not available in py2? on datetime?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. The method was added to the stdlib datetime.datetime in py3.3

dt = ts.to_pydatetime()
assert dt.timestamp() == ts.timestamp() - ts.nanosecond
assert dt.timestamp() == round(ts.timestamp(), 6)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need to round?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because dt.timestamp() is the datetime.timestamp method which only has microsecond-precision.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly, you should not need to do this



class TestTimestampNsOperations(object):
Expand Down