Reputation: 4498
I created 9 pivot tables:
they all look like this
2015
NR_V
0 20.000000
1 20.405677
2 35.982625
3 50.475167
4 61.578472
I want to merge them all by NR_V the way I would merge normal tables, but I think that empty line is throwing it off.
I tried this
dfs = [p_2009, p_2010, p_2011, p_2012, p_2013, p_2014, p_2015 ]
merge = partial(pd.merge, on=['NR_V'], how='outer')
result = dfs[0]
for df in dfs[1:]:
result = merge(result, df)
But I get an error "KeyError: 'NR_V'".
Upvotes: 3
Views: 4279
Reputation: 294488
Try using pd.concat
dfs = [p_2009, p_2010, p_2011, p_2012, p_2013, p_2014, p_2015 ]
pd.concat(dfs, axis=1)
response to comment
If you want to get rid of empty space
pd.concat(dfs, axis=1).reset_index()
Upvotes: 3