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 ?
我认为您将不得不重置索引:
df = df1.reset_index().merge(df2.reset_index(), on=['index','cols']).set_index('index')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.