Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

How to print a groupby object

import pandas as pd
df = pd.DataFrame({'A': ['one', 'one', 'two', 'three', 'three', 'one'], 'B': range(6)})
print(df)
#       A  B
#0    one  0
#1    one  1
#2    two  2
#3  three  3
#4  three  4
#5    one  5

grouped_df = df.groupby('A')

for key, item in grouped_df:
    print(grouped_df.get_group(key), "

")

#             A  B
#A                
#one   0    one  0
#      1    one  1
#      5    one  5
#two   2    two  2
#three 3  three  3
#      4  three  4
Comment

PREVIOUS NEXT
Code Example
Python :: how to iterate through ordereddict in python 
Python :: save model tensorflow 
Python :: async sleep python 
Python :: pandas return specific row 
Python :: python shortest distance between two points 
Python :: 1d array to one hot 
Python :: creating a pandas df 
Python :: pywebcopy 
Python :: pandas group by day 
Python :: remove last line of text file python 
Python :: ardent 
Python :: how to make a random variable in python 
Python :: python get weather 
Python :: Python Django Models Unique Rows 
Python :: hex to rgb python 
Python :: find all color in image python 
Python :: python replace only first instance 
Python :: remove substring from string python 
Python :: split string in python 
Python :: How to change values in a pandas DataFrame column based on a condition in Python 
Python :: how to calculate z score in python 
Python :: selenium get cookies python 
Python :: python xml to csv 
Python :: heroku python buildpack 
Python :: create app in django 
Python :: how to close a python program 
Python :: python map string to int 
Python :: python delete from list 
Python :: data compression in python 
Python :: tkinter simple notification 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =