-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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
Changes from all commits
f01f9a9
f2368f7
5a6cd92
93893da
270c3ba
d19df14
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 |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
from pandas.core.dtypes.common import ( | ||
ensure_platform_int, | ||
is_1d_only_ea_obj, | ||
is_interval_dtype, | ||
) | ||
from pandas.core.dtypes.missing import na_value_for_dtype | ||
|
||
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. yah, this seems like a weird place to special-case |
||
|
||
return arr.take(indexer, fill_value=fill_value, allow_fill=allow_fill) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2281,6 +2281,13 @@ def to_native_types( | |
results_converted.append(result.astype(object, copy=False)) | ||
return np.vstack(results_converted) | ||
|
||
elif isinstance(values, (PeriodArray, IntervalArray)): | ||
# GH46297 | ||
values = np.array(values, dtype="object") | ||
mask = isna(values) | ||
values[mask] = na_rep | ||
return values | ||
Comment on lines
+2284
to
+2289
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 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 commentThe reason will be displayed to describe this comment to others. Learn more. @Kyrpel can you do this one |
||
|
||
elif values.dtype.kind == "f" and not is_sparse(values): | ||
# see GH#13418: no special formatting is desired at the | ||
# output (important for appropriate 'quoting' behaviour), | ||
|
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