I\'ve created a Pandas DataFrame
df = DataFrame(index=[\'A\',\'B\',\'C\'], columns=[\'x\',\'y\'])
and got this
x y A NaN
One way to use index with condition is first get the index of all the rows that satisfy your condition and then simply use those row indexes in a multiple of ways
conditional_index = df.loc[ df['col name'] ].index
Example condition is like
==5, >10 , =="Any string", >= DateTime
Then you can use these row indexes in variety of ways like
df.loc[conditional_index , [col name]]=
df.loc[conditional_index, [col1,col2]]=
df.loc[conditional_index, [col1,col2]]= df.loc[conditional_index,'col name']
This is all possible because .index returns a array of index which .loc can use with direct addressing so it avoids traversals again and again.