-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CI/TST: Don't require length for construct_1d_arraylike_from_scalar cast to float64 #47393
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 4 commits
ceffe6d
d324332
cdcf033
1a82a00
e63d61e
536786f
106449d
2131095
df267f9
ffd1171
57d43c2
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 |
---|---|---|
|
@@ -1696,7 +1696,10 @@ def construct_1d_arraylike_from_scalar( | |
|
||
else: | ||
|
||
if length and is_integer_dtype(dtype) and isna(value): | ||
if is_integer_dtype(dtype) and isna(value): | ||
if not length: | ||
# GH 47391: numpy > 1.24 will raise filling np.nan into int dtypes | ||
return np.array([], dtype=dtype) | ||
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 seems like a weird case. how does it happen? is it clear that we'd want to prioritize the dtype as being "right" instead of the value? 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 posted an example of the state that's reached in numpy/numpy#21784 Namely before this change, 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 the question (also for me from NumPy!) is which pandas code runs into this path. For pandas, the question is what the actual result should be (in the future). For me the question is how bad it will be if that code path breaks. Because especially if it is bad, we may want to make sure it doesn't break yet (from within NumPy). (At this point I suspect that at least the NaN case may need a work-around in NumPy as well.) 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. So an example test where this is hit is
so I think when operating over these empty Series/DataFrames, the value representation is
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. So for these empty-like cases in pandas, it appears pandas was relying on 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. sgtm. (but why not keep this bit unchanged and just put the 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. Ah sure I can make the change there instead |
||
# coerce if we have nan for an integer dtype | ||
dtype = np.dtype("float64") | ||
elif isinstance(dtype, np.dtype) and dtype.kind in ("U", "S"): | ||
|
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.
I think still need the length here as this part of the code is this logic to determine the the dtype
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.
i.e. revert to original.