I have a 3 data frames like this and the shape in each data frame are not the same size.
df
fruits priceyear_2010
orange 15
apple 10
watermelon 3
melon 7
strawberry 11
df1
fruits priceyear_2011
watermelon 5
apple 4
strawberry 19
df2
fruits priceyear_2012
apple 12
orange 16
watermelon 14
melon 18
and I would like to map with the string to get the result like this
df_result
fruits priceyear_2010 priceyear_2011 priceyear_2012
apple 10 4 12
orange 15 Nan 16
watermelon 3 5 14
melon 7 Nan 18
strawberry 11 19 Nan
sorry for asking this but i have no idea.
I have followed the suggestion below and got the ValueError
----> 2 df = pd.concat([x.set_index(['fruits']) for x in dfs], axis = 1)
~/anaconda3/lib/python3.6/site-packages/pandas/core/reshape/concat.py in concat(objs, axis, join, join_axes, ignore_index, keys, levels, names, verify_integrity, sort, copy)
224 verify_integrity=verify_integrity,
225 copy=copy, sort=sort)
--> 226 return op.get_result()
227
228
ValueError: Shape of passed values is (3, 2285), indices imply (3, 2284)