I have big datasets of more than 1 million rows and varying column size(sometimes 1 column or sometimes different number of columns). initially, I created a script, it was working fine. but recently I ran into an issue which can be replicated with the below script.
import pandas as pd
df=pd.DataFrame({'a':[0,0],'b':[100,1]})
df[df>0]='S1'
df[df==0]='S0'
Error:
TypeError: Cannot do inplace boolean setting on mixed-types with a non np.nan value
line 3 and 4 can be interchangeable and the issue will be at the 4th line.
initial df:
a b
0 100
0 1
Expecting df:
a b
S0 S1
S0 S1