I have a function like this:
def number(row):
if row['temp'] == '1 Person':
return 'One'
elif row['temp'] == '2 Persons':
return 'Two'
elif row['temp'] == '3 Persons':
return 'Three'
elif row['temp'] in ['4 Persons','5 Persons', '6 Persons', '7 Persons','8 Persons',
'9 Persons','10 Persons','11 Persons']:
return 'More'
else:
return None
Now, I want to change the values in my data frame looping through row-wise.
How can I loop through my data frame and replace the values according to the function above in Pyspark?