-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: Simplify map_infer_mask #58483
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
CLN: Simplify map_infer_mask #58483
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 |
---|---|---|
|
@@ -627,28 +627,25 @@ def _str_map( | |
na_value = np.nan | ||
else: | ||
na_value = False | ||
try: | ||
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. If you're free, could you review the changes to the Arrow strings here? I think what I have here is correct, but not too familiar with the arrow strings. 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. |
||
result = lib.map_infer_mask( | ||
arr, | ||
f, | ||
mask.view("uint8"), | ||
convert=False, | ||
na_value=na_value, | ||
dtype=np.dtype(cast(type, dtype)), | ||
) | ||
return result | ||
|
||
except ValueError: | ||
result = lib.map_infer_mask( | ||
arr, | ||
f, | ||
mask.view("uint8"), | ||
convert=False, | ||
na_value=na_value, | ||
) | ||
if convert and result.dtype == object: | ||
result = lib.maybe_convert_objects(result) | ||
return result | ||
|
||
dtype = np.dtype(cast(type, dtype)) | ||
if mask.any(): | ||
# numpy int/bool dtypes cannot hold NaNs so we must convert to | ||
# float64 for int (to match maybe_convert_objects) or | ||
# object for bool (again to match maybe_convert_objects) | ||
if is_integer_dtype(dtype): | ||
dtype = np.dtype("float64") | ||
else: | ||
dtype = np.dtype(object) | ||
result = lib.map_infer_mask( | ||
arr, | ||
f, | ||
mask.view("uint8"), | ||
convert=False, | ||
na_value=na_value, | ||
dtype=dtype, | ||
) | ||
return result | ||
|
||
elif is_string_dtype(dtype) and not is_object_dtype(dtype): | ||
# i.e. StringDtype | ||
|
Uh oh!
There was an error while loading. Please reload this page.