I have data frames containing Height data like this
How to change into inches with dtype:float ? thankyou
Try:
df["Heigth_inches"] = (df.Height.str.split("'").str[0].astype(int) * 12) + (
df.Height.str.split("'").str[1].astype(int)
)
print(df)
Prints:
Height Heigth_inches
0 5'7 67
1 6'2 74
2 5'9 69
3 5'11 71
4 5'10 70
EDIT: Changed the computation, thanks @Serge