Jul-14-2019, 10:26 AM
(Jul-13-2019, 12:14 PM)SriMekala Wrote: df['value']=df.loc[df['Status'].str.contains('pass', case=False), 'value'] = 0Doing so you encounter with specificity of chained assignment in Python. This line is equivalent to
temporary = 0 df['value'] = temporary df.loc[...] = temporarySo, you will get a column of zeros.
df.loc[..., 'value']
automatically creates a column if it does not exist, you don't need to create it, e.g. by df['value']
or something else.