Splitting dataframe into multiple dataframes

后端 未结 11 1288
南方客
南方客 2020-11-22 01:16

I have a very large dataframe (around 1 million rows) with data from an experiment (60 respondents).

I would like to split the dataframe into 60 dataframes (a datafra

11条回答
  •  孤城傲影
    2020-11-22 01:34

    The method based on list comprehension and groupby- Which stores all the split dataframe in list variable and can be accessed using the index.

    Example

    ans = [pd.DataFrame(y) for x, y in DF.groupby('column_name', as_index=False)]
    
    ans[0]
    ans[0].column_name
    

提交回复
热议问题