-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
tocsv_interval _categories #46562
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
tocsv_interval _categories #46562
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.
Thanks for the PR!
elif isinstance(values, (PeriodArray, IntervalArray)): | ||
# GH46297 | ||
values = np.array(values, dtype="object") | ||
mask = isna(values) | ||
values[mask] = na_rep | ||
return values |
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.
This is very similar to the EA block below (L2321); can they be combined?
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.
@Kyrpel can you do this one
@@ -110,6 +111,9 @@ def take_nd( | |||
return arr.take( | |||
indexer, fill_value=fill_value, allow_fill=allow_fill, axis=axis | |||
) | |||
if arr.dtype.kind in "O" and is_interval_dtype(arr): | |||
# # GH46297 Interval | |||
return arr.take(indexer, allow_fill=allow_fill) |
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.
fill_value here comes from the na_rep argument of to_csv; is ignoring it the right behavior? Does that mean whatever the user specifies will be ignored?
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.
yah, this seems like a weird place to special-case
elif isinstance(values, (PeriodArray, IntervalArray)): | ||
# GH46297 | ||
values = np.array(values, dtype="object") | ||
mask = isna(values) | ||
values[mask] = na_rep | ||
return values |
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.
@Kyrpel can you do this one
@@ -110,6 +111,9 @@ def take_nd( | |||
return arr.take( | |||
indexer, fill_value=fill_value, allow_fill=allow_fill, axis=axis | |||
) | |||
if arr.dtype.kind in "O" and is_interval_dtype(arr): |
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.
elif
Thanks @Kyrpel for the PR. This fix is currently adding some more code where the regression was caused by a code addition in #44930. pandas/pandas/core/internals/blocks.py Lines 2265 to 2271 in 009c4c6
whereas before #44930 the conversion was done in ... pandas/pandas/core/internals/blocks.py Lines 2318 to 2323 in 009c4c6
Now removing the code addition in #44930 also fixes this issue. Now since the Going back to this issue. we also have the related issue #46812, and I may need to update this observation once I have looked at that one. I suspect that both issues should probably be fixed togther. |
should have been containing Timestamps was also fixed in #18024 -> containing Timestamps #18024 was also fixed in #44930 cc @jbrockmendel @phofl (participants in #44930) |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.