Skip to content

Commit 69084ea

Browse files
committed
update doc-string
1 parent dc6ed74 commit 69084ea

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

pandas/core/frame.py

+27
Original file line numberDiff line numberDiff line change
@@ -4966,6 +4966,33 @@ def apply(self, func, axis=0, broadcast=None, raw=False, reduce=None,
49664966
4 1 2
49674967
5 1 2
49684968
4969+
Return a Series inside the function is similar to passing
4970+
Passing result_type='expand'. The resulting column names
4971+
will be the Series index.
4972+
4973+
>>> df.apply(lambda x: Series([1, 2], index=['foo', 'bar']), axis=1)
4974+
foo bar
4975+
0 1 2
4976+
1 1 2
4977+
2 1 2
4978+
3 1 2
4979+
4 1 2
4980+
5 1 2
4981+
4982+
4983+
Passing result_type='broadcast' will take a same shape
4984+
result, whether list-like or scalar and broadcast it
4985+
along the axis. The resulting column names will be the originals.
4986+
4987+
>>> df.apply(lambda x: [1, 2, 3], axis=1, result_type='broadcast')
4988+
A B C
4989+
0 1 2 3
4990+
1 1 2 3
4991+
2 1 2 3
4992+
3 1 2 3
4993+
4 1 2 3
4994+
5 1 2 3
4995+
49694996
See also
49704997
--------
49714998
DataFrame.applymap: For elementwise operations

0 commit comments

Comments
 (0)