to_sparse and assign is giving the wrong results. #19163
Labels
Dtype Conversions
Unexpected or buggy dtype conversions
Reshaping
Concat, Merge/Join, Stack/Unstack, Explode
Sparse
Sparse Data Type
Milestone
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)
This works as expected if the dataframe is dense i.e
df.to_dense().assign(newcol=False).to_sparse()
Is this a bug or is this a genuine thing that's happening?
The text was updated successfully, but these errors were encountered: