I'm trying to put together two multi-index dataframes. The original dataframes have the same exact columns and similar values and are then grouped by the same columns.
original dataframe example like below (I'm making the columns since actual data is confidential)
| receiver | product_name | sent_time | receive_time | product_count | subcomponent_count_1 | subcomponent_count_2 | packer |
|---|---|---|---|---|---|---|---|
| John LLC | Apple watch | 2021-10-20 | 2021-10-21 | 20 | 10 | 15 | employee1 |
| Sam LLC | Apple pencil | 2021-10-05 | 2021-10-06 | 10 | 7 | 2 | employee1 |
| .. | .. | .. | .. | .. | .. | .. | .. |
the steps I took to transform the dataframes:
df3 = df1.groupby(['receiver','product_name','sent_time','receive_time','product_count']...
df4 = df2.groupby(['receiver','product_name','sent_time','receive_time','product_count']...
df_i_want = pd.concat([df_3,df_4])
However, df_i_want does not have the multi-index structure and is putting all the groupby columns in the same column.
what can do I to put these two multi-index df together (It's not an option to concat df1 and df2 and then do groupby)?
Thanks y'all!
groupby? If you simply want to have a dataframe with all rows ofdf1anddf2, you can just dodf_i_want = df1.append(df2)?