I need to iterate through a dataframe and generate a column that transposes a weekday into its related number.
I've came up with the following:
inputData['DOW'] = ""
for i in range(0,len(inputData)):
if 'Sunday' in inputData.iloc[i]['day_of_the_week']:
inputData.iloc[i]['DOW']=1
elif 'Monday' in inputData.iloc[i]['day_of_the_week']:
inputData.iloc[i]['DOW']=2
elif 'Tuesday' in inputData.iloc[i]['day_of_the_week']:
inputData.iloc[i]['DOW']=3
elif 'Wednesday' in inputData.iloc[i]['day_of_the_week']:
inputData.iloc[i]['DOW']=4
elif 'Thursday' in inputData.iloc[i]['day_of_the_week']:
inputData.iloc[i]['DOW']=5
elif 'Friday' in inputData.iloc[i]['day_of_the_week']:
inputData.iloc[i]['DOW']=6
elif 'Saturday' in inputData.iloc[i]['day_of_the_week']:
inputData.iloc[i]['DOW']=7
But this gives me back the column "DOW" empty for all the rows... What's going wrong here?