0

I am trying to filter a dataframe to create multiple other dataframes based on a list of dictionaries. An example would be to create dataframes one, two, three:

dfa = pd.DataFrame({"ID": ["one", "two", "three"],"Color":["Red", "White", "Blue"],"Length":["16", "14.97", "22.75"]})

What I am trying to get is:

one=dfa[dfa['ID'].astype(str)=='one']

two=dfa[dfa['ID'].astype(str)=='two']

three=dfa[dfa['ID'].astype(str)=='three']

I want to do this over an unlimited number of dataframes so it would be easier to do it programmatically but I appreciate any help you can provide

Shawn Jamal
  • 170
  • 8

0 Answers0