0

So I have a dataframe that looks like this for example:Dataframe

In this example, I need to split the dataframe into multiple dataframes based on the account_id(or arrays because I will convert it anyways). I want each account id (ab123982173 and bc123982173) to be either an individual data frame or array. Since the actual dataset is thousands of rows long, splitting into a temporary array in a loop was my original thought.

Any help would be appreciated.

1 Answers1

1

you can get a subset of your dataframe.

Using your dataframe as example,

subset_dataframe = dataframe[dataframe["Account_ID"] == "ab123982173"]

Here is a link from the pandas documentation that has visual examples: https://pandas.pydata.org/docs/getting_started/intro_tutorials/03_subset_data.html

Rodalm
  • 5,169
  • 5
  • 21
R Kalia
  • 17
  • 2
  • Thats a good idea, but there are thousands of records. I'm gonna try to loop through the account id's and see if I can get however many dataframes that is. – gmelgkermglermgmrelkgm Jun 16 '22 at 18:50
  • I think what you're looking for is answered here : https://stackoverflow.com/questions/44729727/pandas-slice-large-dataframe-into-chunks – R Kalia Jun 17 '22 at 07:30