How do I access data inside a pandas dataframe groupby object? | بلاگ

How do I access data inside a pandas dataframe groupby object?

تعرفه تبلیغات در سایت

آخرین مطالب

امکانات وب

Vote count: 0

Using the following code df_grouped was created.

df_grouped = df.groupby(by='Pclass')

Below a loop prints the Pclass value as well as the length of each grouped amount.

for val,grp in df_grouped:
    print('There were',len(grp),'people traveling in',val,'class.')

How does the code access the information? How can val & grp be used without being referenced earlier? How is this information stored inside the groupby object?

asked 15 secs ago
Vince Miller

...
نویسنده : استخدام کار بازدید : 0 تاريخ : چهارشنبه 7 شهريور 1397 ساعت: 0:56