@@ -521,9 +521,17 @@ Transformation
521
521
--------------
522
522
523
523
The ``transform `` method returns an object that is indexed the same (same size)
524
- as the one being grouped. Thus, the passed transform function should return a
525
- result that is the same size as the group chunk. For example, suppose we wished
526
- to standardize the data within each group:
524
+ as the one being grouped. The transform function must:
525
+
526
+ * Return a result that is either the same size as the group chunk or
527
+ broadcastable to the size of the group chunk.
528
+ * Operate column-by-column on the group chunk. A fast path is used if the
529
+ transform function also operates on the entire group chunk as a DataFrame.
530
+ * Does not perform in-place operations on the group chunk. Group chunks should
531
+ be treated as immutable, and changes to a group chunk may produce unexpected
532
+ results.
533
+
534
+ For example, suppose we wished to standardize the data within each group:
527
535
528
536
.. ipython :: python
529
537
@@ -605,8 +613,9 @@ and that the transformed data contains no NAs.
605
613
606
614
.. note ::
607
615
608
- Some functions when applied to a groupby object will automatically transform the input, returning
609
- an object of the same shape as the original. Passing ``as_index=False `` will not affect these transformation methods.
616
+ Some functions when applied to a groupby object will automatically transform
617
+ the input, returning an object of the same shape as the original. Passing
618
+ ``as_index=False `` will not affect these transformation methods.
610
619
611
620
For example: ``fillna, ffill, bfill, shift ``.
612
621
0 commit comments