-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f9e2ad5
Add timestamp method+test; closes #17329
jbrockmendel aa7b06d
whatsnew entry
jbrockmendel 4155b03
typo fixup tz-->tzinfo
jbrockmendel c73c2fe
fixup python-->Python
jbrockmendel 66d4a2b
Add timestamp method to NaT in py2
jbrockmendel 54ebd13
fix docstring mismatch
jbrockmendel a88419d
add docstring, test against timestamp in py3
jbrockmendel 49accab
add timestamp to api.rst
jbrockmendel 698e688
fixup missing import
jbrockmendel 5eed82b
typo fixup
jbrockmendel 715b740
fix timestamp test
jbrockmendel b7747ec
add test for NaT.timestamp
jbrockmendel 237be98
Move nat timestamp test to test_nat
jbrockmendel a775671
round timestamp to 6 digits; merge nat test
jbrockmendel 8f6d8d5
remove rounding from timestamp test
jbrockmendel 580a1c6
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
jbrockmendel 7992462
move whatsnew to 0.21.1
jbrockmendel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
from pandas._libs import tslib, period | ||
from pandas._libs.tslibs.timezones import get_timezone | ||
|
||
from pandas.compat import lrange, long | ||
from pandas.compat import lrange, long, PY3 | ||
from pandas.util.testing import assert_series_equal | ||
from pandas.compat.numpy import np_datetime64_compat | ||
from pandas import (Timestamp, date_range, Period, Timedelta, compat, | ||
|
@@ -1079,6 +1079,23 @@ def test_is_leap_year(self): | |
dt = Timestamp('2100-01-01 00:00:00', tz=tz) | ||
assert not dt.is_leap_year | ||
|
||
def test_timestamp(self): | ||
# GH#17329 | ||
# tz-naive --> treat it as if it were UTC for purposes of timestamp() | ||
ts = Timestamp.now() | ||
uts = ts.replace(tzinfo=utc) | ||
assert ts.timestamp() == uts.timestamp() | ||
|
||
tsc = Timestamp('2014-10-11 11:00:01.12345678', tz='US/Central') | ||
utsc = tsc.tz_convert('UTC') | ||
# utsc is a different representation of the same time | ||
assert tsc.timestamp() == utsc.timestamp() | ||
|
||
if PY3: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this not available in py2? on datetime? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
# should agree with datetime.timestamp method | ||
dt = ts.to_pydatetime() | ||
assert dt.timestamp() == ts.timestamp() | ||
|
||
|
||
class TestTimestampNsOperations(object): | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can u maker sure test for mat is ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for NaT