-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Fix Series construction with dtype=str #20401
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 7 commits
9569eb3
a188cf7
1844e6e
55f9998
d6aac90
ba2d2c0
81fde6e
41d35ca
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 |
---|---|---|
|
@@ -4059,9 +4059,10 @@ def _try_cast(arr, take_fast_path): | |
if issubclass(subarr.dtype.type, compat.string_types): | ||
# GH 16605 | ||
# If not empty convert the data to dtype | ||
if not isna(data).all(): | ||
data = np.array(data, dtype=dtype, copy=False) | ||
|
||
subarr = np.array(data, dtype=object, copy=copy) | ||
# GH 19853: If data is a scalar, subarr has already the result | ||
if not np.isscalar(data): | ||
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. right but is this still an extra call here? do we need the scalar check? (and should be is_scalar anyhow if its needed) 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. We need a check indeed. That was the problem from the beginning. |
||
if not np.all(isna(data)): | ||
data = np.array(data, dtype=dtype, copy=False) | ||
subarr = np.array(data, dtype=object, copy=copy) | ||
|
||
return subarr |
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.
you don't need all this, just change to use
np.any