0
I have a dataset with two columns and would like to create a third column called Ranking that will receive values based on the Brand column. So Mark A will receive the value 10 and so on.
df = {'Marca' : ['A', 'B', 'C'],
'Valores': ['10', '11', '12']}
df['Ranking'] = df['Marca'].apply(lambda x: x.replace('A','10')
.replace('B', '11')
.replace('C', '12'))
With this function the code worked, however the Ranking column dtype is like Object, then I tried to use df.Ranking.astype(int)
to transform into whole, but when I give a df.dtypes
continues as Object. Is there another way for me to treat this?? This column needs to be numerical as I will use it for modeling later.
Note: the variable df is a Pandas object. Thank you.
Hello @Edi, you could edit your question and add in the tags the library you are using?
– fernandosavio