Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

dataframe groupby to dictionary

In [81]: df.groupby('Column1')['Column3'].apply(list).to_dict()
Out[81]: {0: [1], 1: [2, 3, 5], 2: [1, 2], 3: [4, 5], 4: [1], 5: [1, 2, 3]}
Comment

convert pandas group to dict

res = dict(tuple(d.groupby('a')))
Comment

dataframe groupby to dictionary

In [433]: {k: list(v) for k, v in df.groupby('Column1')['Column3']}
Out[433]: {0: [1], 1: [2, 3, 5], 2: [1, 2], 3: [4, 5], 4: [1], 5: [1, 2, 3]}
Comment

PREVIOUS NEXT
Code Example
Python :: rearrange list python 
Python :: how to reverse a number in python 
Python :: python memoization 
Python :: none address in python 
Python :: install pyaudio linux 
Python :: how to get 2 random inputs in a list using for loop 
Python :: how to check if user is using main file or importing the file and using in python 
Python :: scikit learn ridge regression 
Python :: reverse order np array 
Python :: how to show multiple image in plt.imshow 
Python :: python custom array sort 
Python :: python cache return value 
Python :: plt ax title 
Python :: show pythonpath 
Python :: how to equal two arrays in python with out linking them 
Python :: how to change dtype object to int 
Python :: order dataframe by multiple columns python 
Python :: save matplotlib figure 
Python :: python csv delete specific row 
Python :: print nested list in new lines in python 
Python :: prime number program in python 
Python :: most frequent element in a list 
Python :: python import specific excel sheet 
Python :: tqdm gui 
Python :: leaky relu keras 
Python :: is alphabet python 
Python :: py pause script 
Python :: discord.py commands.group 
Python :: python for doing os command execution 
Python :: python get exception message 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =