-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Change in astype leads to no longer casting to numpy string dtypes #39945
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 all commits
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 |
---|---|---|
|
@@ -287,7 +287,9 @@ def apply( | |
if not ignore_failures: | ||
raise | ||
continue | ||
# if not isinstance(applied, ExtensionArray): | ||
if not isinstance(applied, ExtensionArray): | ||
if issubclass(applied.dtype.type, (str, bytes)): | ||
applied = np.array(applied, dtype=object) | ||
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 think we ought to have a sanitize_str_dtypes or something akin to sanitize_to_nanoseconds 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 is a 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 now done as part of maybe_coerce_values, though that may be more heavy-weight than we want here |
||
# # TODO not all EA operations return new EAs (eg astype) | ||
# applied = array(applied) | ||
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 think this commented out code was from the initial implementation at which point I only supported storing EAs in the ArrayManager, and not numpy.ndarrays. But now both are supported, so you can remove this code. |
||
result_arrays.append(applied) | ||
|
@@ -413,7 +415,10 @@ def downcast(self) -> ArrayManager: | |
return self.apply_with_block("downcast") | ||
|
||
def astype(self, dtype, copy: bool = False, errors: str = "raise") -> ArrayManager: | ||
return self.apply("astype", dtype=dtype, copy=copy) # , errors=errors) | ||
# if issubclass(dtype, (str, bytes)): | ||
# dtype = "object" | ||
y = self.apply("astype", dtype=dtype, copy=copy) # , errors=errors) | ||
return y | ||
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. can the commented-out code be removed? |
||
|
||
def convert( | ||
self, | ||
|
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.
nice!