Reputation: 300
I need to merge two data frames. In df_A the key is an int. In df_B the key is a string ending in .0 e.g. '10003.0'.
I would like to convert the string in df_B to an int for merging. Is there a better way than mapping twice as seen below?
df_B['key'].map(float).map(int)
The syntax seems awkward to me. Is there a better solution?
Upvotes: 1
Views: 53
Reputation: 323326
You can using to_numeric
pd.to_numeric(df_B['key'],downcast='integer')
Upvotes: 5