简体   繁体   中英

How to split dataframe or array by unique column value with multiple unique values

So I have a dataframe that looks like this for example: 数据框

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM