-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: pytables _set_tz/_get_tz #30018
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
Conversation
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.
looks good generally
pandas/io/pytables.py
Outdated
values: Union[np.ndarray, Index], | ||
tz: Optional[Union[str, tzinfo]], | ||
coerce: bool = False, | ||
): |
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.
Is the return easy to annotate here? DTI or Ndarray?
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.
yes, will do
pandas/io/pytables.py
Outdated
coerce : if we do not have a passed timezone, coerce to M8[ns] ndarray | ||
""" | ||
if isinstance(values, DatetimeIndex): | ||
# If we values is tzaware, the tz gets dropped in the values.ravel() |
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.
Is we
a typo?
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.
yes
# call below (which returns an ndarray). So we are only non-lossy | ||
# if `tz` matches `values.tz`. | ||
assert values.tz is None or values.tz == tz | ||
|
||
if tz is not None: | ||
name = getattr(values, "name", None) | ||
values = values.ravel() |
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 wonder if we need the ravel any longer
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 havent checked if we ever actually pass 2D ndarray, but the ravel is definitely needed in the case where we have a DTI (or we would have to replace it with DTI-specific code) (see the comment a few lines up)
ok sure |
removes preserve_UTC argument, which never did anything, and didnt have a clear purpose