I would like to write a function keeping the common index of input dataframes. I could write it as follows for 2 dataframes:
def get_df_common_index(df1, df2): common_index = df1.index.intersection(df2.index) return df1.loc[common_index], df2.loc[common_index]
My question is how to make it a general function which can take multiple inputs and return dataframes accordingly? As if I could use it as follows:
df1, df2, df3, df4 = get_df_common_index(df1, df2, df3, df4)