Jul-11-2019, 02:35 PM
Hi,
I have below DataFrame, I want to replace if row value contains 'pass' with '0'.
but if in case I want to column number (like here in this case 1), how to do it.
I have below DataFrame, I want to replace if row value contains 'pass' with '0'.
1 2 3 4 |
import pandas as pd df = pd.DataFrame({ 'Name' :[ 'NHAY' , 'HAY' , 'UTY' , 'UIK' , 'JUI' , 'YTH' ], 'Status' :[ 'Pass' , 'Running' , 'pass(warning 0)' , 'pass' , 'fail' , 'passed' ]}) df.loc[df[ 'Status' ]. str .contains( 'pass' , case = False ), 'Status' ] = 0 |