BUG: Loc changes dtype when condition is completly False #37550
Labels
Bug
Dtype Conversions
Unexpected or buggy dtype conversions
Indexing
Related to indexing on series/frames, not to indexes themselves
Milestone
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Thus converts
b
to float and returnsProblem description
[this should explain why the current behaviour is a problem and why the expected output is a better solution]
Expected Output
Would expect that this returns an integer.
Interestingly, this is returned if we drop the column
a
.or if we are not using df["c"] and an integer instead.
Both return
1
instead of1.0
for columnb
Edit: The condition [False] is just a simplification. This also happens if we use a condition, which evaluates sometimes to completly False based on the input data.
Output of
pd.show_versions()
master
The text was updated successfully, but these errors were encountered: