-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: identity checking NA in map incorrect #58392
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 24 commits
68b6c7c
dcc8dab
19215b7
b916372
539bf7e
616620c
8473e73
1d49ac0
a5bf510
a17d8b5
1f2965c
70c2b8a
584c1ca
c7fe27b
492d167
557bce1
49596c9
5eb85ff
4f5cfe5
32ceaa3
816a0d2
d2acb4a
7cb37df
5d7ad8b
b9631a3
6c85b64
c84932f
421e779
25c2b90
23c48d2
d498b54
a206c94
b36b581
6375701
eda7702
9ab6602
0da8920
e8bce29
14e8973
d0d8ea2
5e3ad28
c9dd068
d1b6a28
3ccc4fd
996d99a
a60b23a
505bdec
17f46c2
528c6ab
fa9a2f2
92ed4ef
ff28d74
ee088d4
2f84261
259b423
0067edf
ac6d324
547662d
e94997a
f93dc66
963f99a
e92152e
f8deed6
b90af02
26a6fb7
fa46a96
d6264e6
237926d
247e9d8
0fc4b60
d60b7e9
6b5c8db
8578b1e
3fb8b0d
b7de292
a42048f
4c61857
2d92818
56f8f16
88a54f7
6dbbf13
72eca60
d8a70b4
ec16f75
69269d7
d7d0614
0f242b2
d293ce6
d19fb2c
9363be6
58de9ac
434cb7e
adc8493
83d7093
df473d7
4cb8fcf
20dd8e1
45bc299
e38dac0
5fb2d6c
a92fb75
d8005ed
9900710
dfdf6ed
451f055
a836ad1
01a8d88
0f3bfaa
1221069
d70be9d
b77da73
ad8494a
0ad45c7
f73e7b6
972957c
4f6fd09
59d4c3e
b8f8e23
41c13f3
f87ee61
48c2dd5
d5aeef2
9cd640f
05c01e6
1244406
47e3c24
18ae900
1df0396
20de040
7798eee
a88295f
e09f878
55b8992
f7d875c
4f7574f
77965c3
a01b55e
f5efabc
d8c0219
a89373c
89b872f
d9f9319
038cfb8
a885b7a
d344841
0b56b9c
93bb8d7
bc04ec7
a03357e
646a85d
b4adcad
efc2600
d4b5396
5c1c726
7c6fdb2
8f18e41
1945ce6
e2f2482
a5d3b74
e6d9f48
3447e1a
6f0beb6
d6ae469
d47c9b6
a9cce25
c673338
ebcce09
43b6b5a
dcab913
2801cc0
04df901
7bbc88b
3d3e473
183b6e6
8c3050c
25a9d35
c10a244
ebb8d26
53a885c
acfe152
f84cd8b
3784b5e
f1fb54e
e54dcdb
ba7d37d
1ab81c0
985598b
c23f65b
d1a8190
f7f6578
39fd9bc
7f45b06
651d37f
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 |
---|---|---|
|
@@ -1678,9 +1678,23 @@ def map_array( | |
if not len(arr): | ||
return arr.copy() | ||
|
||
# we must convert to python types | ||
values = arr.astype(object, copy=False) | ||
na_value = None | ||
mask = isna(arr) | ||
if isinstance(arr.dtype, BaseMaskedDtype) and na_action is None: | ||
arr = cast("BaseMaskedArray", arr) | ||
values = arr._data | ||
if arr._hasna: | ||
na_value = arr.dtype.na_value | ||
else: | ||
# we must convert to python types | ||
values = arr.astype(object, copy=False) | ||
|
||
if na_action is None: | ||
return lib.map_infer(values, mapper) | ||
return lib.map_infer( | ||
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. What happens when the called mapping returns 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. You're right, but strangely, it depends of the input dtype, for example with Case 1) -
In this case data are converted to a Case 2) -
In this case data are converted to an Maybe it is linked to (I will investigate this problem) 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. For information I'm struggling a bit, but I think that I have almost a solution :-) |
||
values, | ||
mapper, | ||
mask=mask, | ||
na_value=na_value, | ||
) | ||
else: | ||
return lib.map_infer_mask(values, mapper, mask=isna(values).view(np.uint8)) | ||
return lib.map_infer_mask(values, mapper, mask=mask) |
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.
It seems to me we want to be doing this for all EAs, not just masked ones.
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.
@rhshadrach: Hello Richard, thanks for your feedback. I'm agree it is a partial solution to the issue (a solution limited to
BaseMaskedArray
).One solution could be to replace the following code in the function
map_array
:by this one (taking into account
ExtensionArray
):Nevertheless, this code just extracts from an array:
pd.NA
,np.nan
, ...)So, maybe this pattern (if I understood correctly what Will was saying :-)) is already managed somewhere else in the code (or I could adapt it) ?
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.
Not that I am aware of, but I might just not be aware.