I'm trying to iterate each row in a Pandas dataframe named 'cd'. If a specific cell, e.g. [row,empl_accept] in a row contains a substring, then updates the value of an other cell, e.g.[row,empl_accept_a] in the same dataframe.
for row in range(0,len(cd.index),1):
if 'Master' in cd.at[row,empl_accept]:
cd.at[row,empl_accept_a] = '1'
else:
cd.at[row,empl_accept_a] = '0'
The code above not working and jupyter notebook displays the error:
TypeError Traceback (most recent call last)
<ipython-input-70-21b1f73e320c> in <module>
1 for row in range(0,len(cd.index),1):
----> 2 if 'Master' in cd.at[row,empl_accept]:
3 cd.at[row,empl_accept_a] = '1'
4 else:
5 cd.at[row,empl_accept_a] = '0'
TypeError: argument of type 'float' is not iterable
I'm not really sure what is the problem there as the for loop contains no float variable.