Skip to content Skip to sidebar Skip to footer

Pandas Multiple Dataframes From Other Dataframes

Suppose I have a base 'test' dataframe of varying length, which I am constructing based off of a slider date selector. seasons test 2018-02-19 Winter 2018-02-20

Solution 1:

Building off of @Mayeul sgc's comment for a multiple case scenario and for the benefit of anyone looking for an answer to the same question: you can do the following:

merged_dataframes = []
# first put all dataframes in a list
supermarkets = [loblaws, wal_mart, whole_foods]
# then use a for loop and Mayeul sgc's clever code:fordfin supermarkets:
    df = df.transpose()
    merged_dataframe = pd.merge(test, df, left_on='seasons', right_index = True)
    merged_dataframes.append(merged_dataframe)

Hope this works for you. Let me know if you needed something else.

Post a Comment for "Pandas Multiple Dataframes From Other Dataframes"