So I have two dataframes and am adding a column to df1 from df2 by using pd.merge
It works fine, only with small problem that it adds 5 decimal. So to show it is like this:
df1
room | value
A | 10
B | 19
df2
name | room | value | value2
Joe | A | 10 | 10.00000
Peter | B | 19 | 19.00000
Can I combine the round().astype(int) with pd.merge?
Current:
final = pd.merge(left=df1, right=df2, on="room", how="left")
Idea (which gives error "Cannot convert non-finite values (NA or inf) to integer"):
final = pd.merge(left=df1, right=df2, on="room", how="left").round().astype(int)
In a previous case I extracted that row with .round().astype(int) and then added that row to a new df by using merge. So with that extra step it worked. Just wondering if a more direct way also exists.
Thanks for any advice.
Best regards
Mitch