-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: preserve timezone info when writing empty tz-aware series to HDF5 #37072
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 12 commits
9ceb1a8
2253258
d2afc6b
7314aed
9158b2b
b5d5785
b5966e5
754b8a9
60d03de
4239a9b
3bcd58f
a60d4cf
c424042
05f509c
579dbea
da0563c
a276602
47b5746
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 |
---|---|---|
|
@@ -2968,11 +2968,17 @@ def write_array_empty(self, key: str, value: ArrayLike): | |
node._v_attrs.value_type = str(value.dtype) | ||
node._v_attrs.shape = value.shape | ||
|
||
def write_array(self, key: str, value: ArrayLike, items: Optional[Index] = None): | ||
# TODO: we only have one test that gets here, the only EA | ||
def write_array(self, key: str, obj: Series, items: Optional[Index] = None): | ||
# TODO: we only have a few tests that get here, the only EA | ||
# that gets passed is DatetimeArray, and we never have | ||
# both self._filters and EA | ||
assert isinstance(value, (np.ndarray, ABCExtensionArray)), type(value) | ||
|
||
if isinstance(obj, (np.ndarray, ABCExtensionArray)): | ||
value = obj | ||
elif is_datetime64tz_dtype(obj): | ||
value = obj.dt._get_values() | ||
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 dont know off the top of my head what _get_values returns, is it a DatetimeArray? The standard pattern would be to use 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 actually the |
||
else: | ||
value = obj.to_numpy() | ||
|
||
if key in self.group: | ||
self._handle.remove_node(self.group, key) | ||
|
@@ -3077,7 +3083,7 @@ def read( | |
def write(self, obj, **kwargs): | ||
super().write(obj, **kwargs) | ||
self.write_index("index", obj.index) | ||
self.write_array("values", obj.values) | ||
self.write_array("values", obj) | ||
self.attrs.name = obj.name | ||
|
||
|
||
|
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 annotation of obj as a Series accurate? if so, this branch is never hit
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.
No it's not. Should be SeriesOrFrame (will fix)