I want to convert hex in column x into correct negative int as seen in column "true", but instead i got result in column y.
x y true
fdf1 65009 -527
I tried this (I know it's not correct)
df["y"] = df["x"].apply(int,base=16)
and from this link I know this function:
def s16(value):
return -(value & 0x8000) | (value & 0x7fff)
a = s16(int('fdf1', 16))
print(a)
can convert single value into correct one but how do you apply it to make a new column in Pandas data frame?