-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Timestamp retains frequency of input Timestamps #23503
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
Changes from 2 commits
232c29b
4f34c01
a14776e
41fcdd7
5854b88
2dcb1fb
218e418
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 |
---|---|---|
|
@@ -30,6 +30,7 @@ from np_datetime import OutOfBoundsDatetime | |
from np_datetime cimport (reverse_ops, cmp_scalar, check_dts_bounds, | ||
npy_datetimestruct, dt64_to_dtstruct) | ||
from offsets cimport to_offset | ||
from offsets import _BaseOffset | ||
from timedeltas import Timedelta | ||
from timedeltas cimport delta_to_nanoseconds | ||
from timezones cimport ( | ||
|
@@ -731,8 +732,11 @@ class Timestamp(_Timestamp): | |
if ts.value == NPY_NAT: | ||
return NaT | ||
|
||
if is_string_object(freq): | ||
if is_string_object(freq) or isinstance(freq, _BaseOffset): | ||
freq = to_offset(freq) | ||
else: | ||
# GH 22311: Try to extract the frequency of a given Timestamp input | ||
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. What do we expect it to be in this case? Aside from None I guess 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. This can be a 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. IIUC you're referring to 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. Ah sorry for misunderstanding. You're correct in that this is essentially swallowing any nonsense frequency and just returning 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.
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. Won't this silently pass if |
||
freq = getattr(ts_input, 'freq', None) | ||
|
||
return create_timestamp_from_ts(ts.value, ts.dts, ts.tzinfo, freq) | ||
|
||
|
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.
don't do this as could have an adverse perf impact (this is a python object). use
is_offset_object