-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: to_csv casting datetimes in categorical to int #44930
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
80a0914
84ecc33
aa15109
187db9d
bc2cd3d
7d61d42
3c23202
fc5d273
d776d92
22e58a2
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 |
---|---|---|
|
@@ -108,6 +108,7 @@ | |
) | ||
import pandas.core.common as com | ||
from pandas.core.construction import ( | ||
ensure_wrapped_if_datetimelike, | ||
extract_array, | ||
sanitize_array, | ||
) | ||
|
@@ -532,7 +533,12 @@ def astype(self, dtype: AstypeArg, copy: bool = True) -> ArrayLike: | |
else: | ||
# GH8628 (PERF): astype category codes instead of astyping array | ||
try: | ||
new_cats = np.asarray(self.categories) | ||
if is_datetime64_dtype(self.categories): | ||
values = ensure_wrapped_if_datetimelike(np.asarray(self.categories)) | ||
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. tz aware datetimes are alreday handled correctly 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 was thinking it might be a perf improvement for dt64tz, but either way its fine to consider that out of scope for this PR |
||
new_cats = values._format_native_types() | ||
else: | ||
new_cats = np.asarray(self.categories) | ||
|
||
new_cats = new_cats.astype(dtype=dtype, copy=copy) | ||
fill_value = lib.item_from_zerodim(np.array(np.nan).astype(dtype)) | ||
except ( | ||
|
Uh oh!
There was an error while loading. Please reload this page.