2

I am trying to move from R to python pandas. I am not an expert and would welcome help. I have searched! I have a dataframe, sh_tags in R with a column thumbs_id which is in hex. I convert it to decimal like this:

sh_tags$thumb_id <- as.integer(paste("0x",sh_tags$thumbs, sep=""))

I can convert a single cell in pandas like this: int(thumb_id .iloc[1,0],16)

But I want to do the column.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
Richard Gott
  • 21
  • 1
  • 2

1 Answers1

5

For a Series:

x = pd.Series(["ff","cd","1a"])
b16 = lambda x: int(x,16)
x.apply(b16)

seems to work

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453