Should I use the dictionary or the series to hold a bunch of dataframe?
Method 2 also works. Since Python 3.6 it remembers the order it is created too.
Suppose I have several dataframes: df1, df2, df3, etc. The label with each dataframes is A1, A2, A3 etc. I want to use this information as a whole, so that I can pass them. Three methods came into my mind:
method 1
use a label list: labels=["A1", "A2", "A3"...] and a list of dataframes dfs=[df1, df2, df3...].
method 2
use a dictionary: d={"A1": df1, "A2": df2, "A3": df3}.
method 3
use a pandas series: s=pd.Series([df1, df2, df3], index=["A1", "A2", "A3"]).
I will use the label and dataframes sequentially, therefore I think method1 and method3 should be my choice. However, using method 1 will need me to pass two items, while using method 3 I only need to keep one object. Is it a common practice to put the dataframes in a series? I seldom see people do this, is it against best practice? Is there any better suggestions?