-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
BUG: pandas Timestamp tz_localize and tz_convert do not preserve freq
attribute
#25247
Changes from 2 commits
bb5731d
8910104
bdd8b2e
64b1a88
9fc0b0a
c65a35c
d4a1515
2734a3b
e514a23
89af164
45d7b01
6666ea5
d923ddf
115b87c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,3 +66,12 @@ def test_length_zero_copy(dtype, copy): | |
arr = np.array([], dtype=dtype) | ||
result = conversion.ensure_datetime64ns(arr, copy=copy) | ||
assert result.base is (None if copy else arr) | ||
|
||
|
||
def test_tz_convert_freq(): | ||
import pandas as pd | ||
import pytz | ||
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. Don't need to import this. Just the string |
||
t1 = pd.Timestamp('2019-01-01 10:00', freq='H') | ||
assert t1.tz_localize(pytz.utc).freq == t1.freq | ||
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. Just assert the 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. but i assume 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. I guess as mentioned below. I was incorrect in assuming the freq would be compared as well. |
||
t2 = pd.Timestamp('2019-01-02 12:00', tz=pytz.utc, freq='T') | ||
assert t2.tz_convert(pytz.utc).freq == t2.freq | ||
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. These four lines look nice. I think these tests would fit better in One other thought: you could add a case where |
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 you use the
tz_naive_fixture
. Ensures we also testtz_localize(None)
as well.