Issue
I have two dataframes, one 18x30 (called df1) and one 2x30 (called df2), both of them have exactly the same index values.
I want to be able to add one of the columns from df2 to the end of df1.
The data types in df1 are all integer and the data type for df2 is string. Whenever I merge/concat/join, I get NaN instead of the right data.
Any help would be greatly appreciated
Thanks :D
Solution
The data types in df1 are all integer and the data type for df2 is string. Whenever I merge/concat/join, I get NaN instead of the right data.
If you want to add the df2 value to the df1 value, you need to convert the df2 field to an integer.
df2['FieldName'] = df2['FieldName'].astype(int)
Answered By - cggarvey
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.