Q:

Pandas: Search for dataframe row by string then modify [without header]

A bit of pickle. I am trying to find a single row in a dataframe by searching for a specific string value, then replace the string value with zero. I am using the following code:
selectRow = df[df.iloc[:,0].str.match(ID)]

selectRow.replace(ID, 0)

where ID is some string. 
This returns one row within the dataframe as expected.
However, I can't seem to modify the values of the selectRow in dataframe, as the selectRow is a separate dataframe at this point. 
I know I am missing something incredibly basic. 
Any help would be much appreciated!
CN

A:

You could do it in a single line as follows:  
Method-1:
ID = `eee`
df.iloc[:,0].loc[df.iloc[:,0]==ID] = 0

Output:  
        C1   C2
0      aaa  bbb
1      ccc  ddd
2        0  fff
3  ggg eee  hhh

Method-2:
Use pandas.Dataframe.replace method.
df.iloc[:,0].replace(to_replace=ID, value=0, regex=False)

Output:  
        C1   C2
0      aaa  bbb
1      ccc  ddd
2        0  fff
3  ggg eee  hhh

If you set regex=True, that could adjust the rows based on other occurrences of the ID as well.
Output:  
        C1   C2
0      aaa  bbb
1      ccc  ddd
2        0  fff
3        0  hhh

Dummy Data
df = pd.DataFrame([['aaa','bbb'],['ccc','ddd'],['eee','fff'],['ggg eee','hhh']], columns=['C1','C2'])
print(df)

Output:  
        C1   C2
0      aaa  bbb
1      ccc  ddd
2      eee  fff
3  ggg eee  hhh

