我需要遍历一个数据帧并生成一列,该列将工作日转换为其相关数字.
我得出了以下结论:
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
但这让我返回所有行的"DOW"列为空...这里怎么了?