Skip to content Skip to sidebar Skip to footer

Sub-select A Multi-index Pandas Dataframe To Create Multiple Subsets (using A Dictionary)

I have a dataset similar to the following: df_lenght = 240 df = pd.DataFrame(np.random.randn(df_lenght,2), columns=['a','b'] ) df['datetime'] = pd.date_range('23/06/2017', periods=

Solution 1:

You could unpack a groupby object into a dictionary:

dfs = {job: df for job, df in df.groupby(level='job_id')}

Post a Comment for "Sub-select A Multi-index Pandas Dataframe To Create Multiple Subsets (using A Dictionary)"