I have a pandas data frame. In one of the columns ('Q8') of this data frame, some of the rows are empty. I would like to replace these empty cells with a string ('ss'). I want to do this replacement with a condition. This condition is that if the string in column ('Q7') is ('I am a student') and the cell in this row at column ('Q8') is empty, replace the empty cell of column ('Q8') with 'ss'.
This is the code which I wrote for it:
for xx in range(0,len(df['Q8'])):
if df['Q8'][xx]==np.nan:
if df['Q7'][xx]=='I am a student':
df['Q8'][xx].replace('', 'ss', regex=True)
but it can not find any np.nan from the first if!!