pandas convert hex string to int 1

pandas convert hex string to int

res = df['Command0'].apply(int, base=16)

print(res)

0    456
1    195
Name: Command0, dtype: int64

Here is what the above code is Doing:
1. The apply() method is called on the column ‘Command0’ of the dataframe df.
2. The function int() is passed as an argument to the apply() method.
3. The base argument is passed to the int() function.
4. The int() function is called on each element of the column ‘Command0’ and the result is stored in the new column ‘res’.

Similar Posts