@@ -66,12 +66,24 @@ pandas objects can be split on any of their axes. The abstract definition of
66
66
grouping is to provide a mapping of labels to group names. To create a GroupBy
67
67
object (more on what the GroupBy object is later), you may do the following:
68
68
69
- .. code-block :: python
69
+ .. ipython :: python
70
+
71
+ df = pd.DataFrame(
72
+ [(' bird' , ' Falconiformes' , 389.0 ),
73
+ (' bird' , ' Psittaciformes' , 24.0 ),
74
+ (' mammal' , ' Carnivora' , 80.2 ),
75
+ (' mammal' , ' Primates' , np.nan),
76
+ (' mammal' , ' Carnivora' , 58 )],
77
+ index = [' falcon' , ' parrot' , ' lion' , ' monkey' , ' leopard' ],
78
+ columns = (' class' , ' order' , ' max_speed' )
79
+ )
80
+
81
+ df
70
82
71
- # default is axis=0
72
- >> > grouped = obj .groupby(key )
73
- >> > grouped = obj .groupby(key , axis = 1 )
74
- >> > grouped = obj .groupby([key1, key2 ])
83
+ # default is axis=0
84
+ grouped = df .groupby(' class ' )
85
+ grouped = df .groupby(' order ' , axis = ' columns ' )
86
+ grouped = df .groupby([' class ' , ' order ' ])
75
87
76
88
The mapping can be specified many different ways:
77
89
0 commit comments