-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
Dtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsReshapingConcat, Merge/Join, Stack/Unstack, ExplodeConcat, Merge/Join, Stack/Unstack, ExplodeSparseSparse Data TypeSparse Data Type
Milestone
Description
Coming from SO, when a boolean scalar is assigned to a new column using assign
, it is leading to wrong results. Why is that so?
df = pd.DataFrame({"a":[1,2,3]}).to_sparse(fill_value=False)
df.assign(newcol=False)
a newcol
0 1 0.0
1 2 0.0
2 3 0.0
This works as expected if the dataframe is dense i.e
df.to_dense().assign(newcol=False).to_sparse()
a newcol
0 1 False
1 2 False
2 3 False
Is this a bug or is this a genuine thing that's happening?
Metadata
Metadata
Assignees
Labels
Dtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsReshapingConcat, Merge/Join, Stack/Unstack, ExplodeConcat, Merge/Join, Stack/Unstack, ExplodeSparseSparse Data TypeSparse Data Type