Answers for "ow to print groupby"

0

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), "nn")

#             A  B
#A                
#one   0    one  0
#      1    one  1
#      5    one  5
#two   2    two  2
#three 3  three  3
#      4  three  4
Posted by: Guest on June-28-2021
1

print groupby dataframe

from IPython.display import display
df.groupby("colName").apply(display)
Posted by: Guest on August-09-2021
-2

pandas print groupby

grp = df.groupby['colName']
grp.describe()
Posted by: Guest on June-06-2020

Python Answers by Framework

Browse Popular Code Answers by Language