This is my input data, which is stored in dataframe df.

Now i want to change all the values in column B to Yearly format. Here is my code:
D = []
for i in df['B']:
for j in df['C']:
if j == 'Year':
D.append(int(i)/1)
elif j == 'Month':
D.append(int(i)/12)
elif j == 'Day':
D.append(int(i)/365)
print(len(df))
print(len(D))
While my original df only has len of 10, the output (list D) has len of 100. Anyone knows how to fix the issue here?
>Solution :
You can try with map
df['D'] = df['B'].div(df['C'].map({'Year':1, 'Month':12, 'Day':365})