-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
NaN is converted to strings when reassigning a column with .loc #28403
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
Labels
Dtype Conversions
Unexpected or buggy dtype conversions
Indexing
Related to indexing on series/frames, not to indexes themselves
Missing-data
np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Needs Tests
Unit test(s) needed to prevent regressions
Milestone
Comments
Thanks for the report, probably a bug. Note that this is following the numpy behavior In [23]: np.array(['a', np.nan])
Out[23]: array(['a', 'nan'], dtype='<U3') I suspect that when df['A'] is presently an object-dtype column, we don't convert the incoming list-like with the right sanitizer. Note that this wouldn't be a problem with a proper StringDtype: #27949 |
#28176 might fix this actuallly |
Works on master, could use a test. |
take |
NumberPiOso
added a commit
to NumberPiOso/pandas
that referenced
this issue
Jan 29, 2022
3 tasks
NumberPiOso
added a commit
to NumberPiOso/pandas
that referenced
this issue
Jan 31, 2022
mroeschke
pushed a commit
that referenced
this issue
Feb 3, 2022
phofl
pushed a commit
to phofl/pandas
that referenced
this issue
Feb 14, 2022
* TST: Nan must not be converted to string Closes pandas-dev#28403 * TST: Add test specific to the issue pandas-dev#28403 * TST: Parametrize multiple inputs change nan loc
yehoshuadimarsky
pushed a commit
to yehoshuadimarsky/pandas
that referenced
this issue
Jul 13, 2022
* TST: Nan must not be converted to string Closes pandas-dev#28403 * TST: Add test specific to the issue pandas-dev#28403 * TST: Parametrize multiple inputs change nan loc
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Dtype Conversions
Unexpected or buggy dtype conversions
Indexing
Related to indexing on series/frames, not to indexes themselves
Missing-data
np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Needs Tests
Unit test(s) needed to prevent regressions
Hello team,
Here is a simple working exemple of value assignment on a dataframe:
However, if we use loc to assign the entire column with an array including NaNs, all values are converted to strings, breaking notna():
The text was updated successfully, but these errors were encountered: