Skip to content Skip to sidebar Skip to footer

Convert The Last Column Of A Data Frame From Hex To Decimal

I have a data frame that I want to filter. I would like to convert the values in the last column from hex to decimal. Is there a way to do it without specifying the name of the col

Solution 1:

Try:

df[df.columns[-1]] = df[df.columns[-1]].apply(int,base=16)

>>> df
  Name Class  Color  Count
0  Ron    G3   Pink      2
1  Jos    G2  Green     10
2  Pam    G5   Blue     15

Post a Comment for "Convert The Last Column Of A Data Frame From Hex To Decimal"