0

Is there a way to concat, join or merge dataframes based on both the index and columns? For example, suppose I have a list of dataframes and I want something like

df = pandas.fullConcat(dfList)

where df.index should be the union of the indices in dfList ('outer' join) and df.columns should also be the union of the columns in dfList. I think all of the concat, join and merge methods just do a join on either the index or the column. I suppose a workaround is stack/unstack or reset_index? Do i miss something ?

1
  • Maybe it makes sense that the joins can only occur on one multi-index at a time. When you have both MultiIndexes and multi-dimensional indexed arrays, the options are many. As a 'work flow' t seems that working with a single MultiIndex during aggregation of data makes the most sense. Commented Feb 22, 2013 at 23:06

1 Answer 1

2

I think you're going to have to reset the index:

df = df1.reset_index().merge(df2.reset_index(), on=['index','cols']).set_index('index')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.