You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -753,7 +801,7 @@ To select from a DataFrame or Series the nth item, use the nth method:
753
801
754
802
g.nth(-1)
755
803
756
-
If you want to select the nth not-null method, use the dropna kwarg. For a DataFrame this should be either 'any' or 'all' just like you would pass to dropna, for a Series this just needs to be truthy.
804
+
If you want to select the nth not-null method, use the dropna kwarg. For a DataFrame this should be either 'any' or 'all' just like you would pass to dropna, for a Series this just needs to be truthy.
757
805
758
806
.. ipython:: python
759
807
@@ -787,6 +835,9 @@ To see the order in which each row appears within its group, use the
787
835
Examples
788
836
--------
789
837
838
+
Regrouping by factor
839
+
~~~~~~~~~~~~~~~~~~~~
840
+
790
841
Regroup columns of a DataFrame according to their sum, and sum the aggregated ones.
791
842
792
843
.. ipython:: python
@@ -796,6 +847,9 @@ Regroup columns of a DataFrame according to their sum, and sum the aggregated on
796
847
df.groupby(df.sum(), axis=1).sum()
797
848
798
849
850
+
Returning a Series to propogate names
851
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
852
+
799
853
Group DataFrame columns, compute a set of metrics and return a named Series.
800
854
The Series name is used as the name for the column index. This is especially
801
855
useful in conjunction with reshaping operations such as stacking in which the
@@ -808,7 +862,7 @@ column index name will be used as the name of the inserted column:
808
862
'b': [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],
809
863
'c': [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],
810
864
'd': [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],
811
-
})
865
+
})
812
866
813
867
defcompute_metrics(x):
814
868
result = {'b_sum': x['b'].sum(), 'c_mean': x['c'].mean()}
0 commit comments