How To Assign Value To A Pandas Dataframe, When Subset By Complex Index And Boolean Based Conditions?
I would like to replace values in a pandas dataframe, with a complex subsetting pattern. With the .loc accessor, I was only able to subset by chaining multiple conditions, because
Solution 1:
You can do with one .loc
chain of loc
assignment will be not safe
df.loc[df.index.isin(['2019-01-05','2019-01-09'])&df.a.eq('foo'),'b']=np.nan
Post a Comment for "How To Assign Value To A Pandas Dataframe, When Subset By Complex Index And Boolean Based Conditions?"