I'm quite new to python so bear with me if this is obvious.
I've got a column, 'age', in a dataframe, dff, containing the values 1 to 66. Each value corresponds to a key in the dictionary, di, and I'm trying to replace the values in the column with the corresponding values from the dictionary.
I can do this for a single value, for example:
dff['age'] = dff['age'].replace('1', di.get('1'))
But I want to do it for all 66 values. I tried this:
i = 1
while i <= 66:
i = str(i)
dff['age'] = dff['age'].replace(i, di.get(i))
i = int(i)
i = i + 1
Which doesn't seem to change the values in the column at all. Any ideas? Thanks.