Skip to content

Commit

Permalink
update doc-string
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback committed Feb 7, 2018
1 parent dc6ed74 commit 69084ea
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4966,6 +4966,33 @@ def apply(self, func, axis=0, broadcast=None, raw=False, reduce=None,
4 1 2
5 1 2
Return a Series inside the function is similar to passing
Passing result_type='expand'. The resulting column names
will be the Series index.
>>> df.apply(lambda x: Series([1, 2], index=['foo', 'bar']), axis=1)
foo bar
0 1 2
1 1 2
2 1 2
3 1 2
4 1 2
5 1 2
Passing result_type='broadcast' will take a same shape
result, whether list-like or scalar and broadcast it
along the axis. The resulting column names will be the originals.
>>> df.apply(lambda x: [1, 2, 3], axis=1, result_type='broadcast')
A B C
0 1 2 3
1 1 2 3
2 1 2 3
3 1 2 3
4 1 2 3
5 1 2 3
See also
--------
DataFrame.applymap: For elementwise operations
Expand Down

0 comments on commit 69084ea

Please sign in to comment.