@@ -4808,70 +4808,67 @@ def aggregate(self, func, axis=0, *args, **kwargs):
4808
4808
4809
4809
agg = aggregate
4810
4810
4811
- _shared_docs ['apply' ] = ("""
4812
- Applies function along input axis of DataFrame.
4811
+ def apply (self , func , axis = 0 , broadcast = False , raw = False , reduce = None ,
4812
+ args = (), ** kwds ):
4813
+ """Applies function along input axis of DataFrame.
4813
4814
4814
- Objects passed to functions are Series objects having index
4815
- either the DataFrame's index (axis=0) or the columns (axis=1).
4816
- Return type depends on whether passed function aggregates, or the
4817
- reduce argument if the DataFrame is empty.
4815
+ Objects passed to functions are Series objects having index
4816
+ either the DataFrame's index (axis=0) or the columns (axis=1).
4817
+ Return type depends on whether passed function aggregates, or the
4818
+ reduce argument if the DataFrame is empty.
4818
4819
4819
- Parameters
4820
- ----------
4821
- func : function
4822
- Function to apply to each column/row
4823
- axis : {0 or 'index', 1 or 'columns'}, default 0
4824
- * 0 or 'index': apply function to each column
4825
- * 1 or 'columns': apply function to each row
4826
- broadcast : boolean, default False
4827
- For aggregation functions, return object of same size with values
4828
- propagated
4829
- raw : boolean, default False
4830
- If False, convert each row or column into a Series. If raw=True the
4831
- passed function will receive ndarray objects instead. If you are
4832
- just applying a NumPy reduction function this will achieve much
4833
- better performance
4834
- reduce : boolean or None, default None
4835
- Try to apply reduction procedures. If the DataFrame is empty,
4836
- apply will use reduce to determine whether the result should be a
4837
- Series or a DataFrame. If reduce is None (the default), apply's
4838
- return value will be guessed by calling func an empty Series (note:
4839
- while guessing, exceptions raised by func will be ignored). If
4840
- reduce is True a Series will always be returned, and if False a
4841
- DataFrame will always be returned.
4842
- args : tuple
4843
- Positional arguments to pass to function in addition to the
4844
- array/series
4845
- Additional keyword arguments will be passed as keywords to the function
4846
-
4847
- Notes
4848
- -----
4849
- In the current implementation apply calls func twice on the
4850
- first column/row to decide whether it can take a fast or slow
4851
- code path. This can lead to unexpected behavior if func has
4852
- side-effects, as they will take effect twice for the first
4853
- column/row.
4820
+ Parameters
4821
+ ----------
4822
+ func : function
4823
+ Function to apply to each column/row
4824
+ axis : {0 or 'index', 1 or 'columns'}, default 0
4825
+ * 0 or 'index': apply function to each column
4826
+ * 1 or 'columns': apply function to each row
4827
+ broadcast : boolean, default False
4828
+ For aggregation functions, return object of same size with values
4829
+ propagated
4830
+ raw : boolean, default False
4831
+ If False, convert each row or column into a Series. If raw=True the
4832
+ passed function will receive ndarray objects instead. If you are
4833
+ just applying a NumPy reduction function this will achieve much
4834
+ better performance
4835
+ reduce : boolean or None, default None
4836
+ Try to apply reduction procedures. If the DataFrame is empty,
4837
+ apply will use reduce to determine whether the result should be a
4838
+ Series or a DataFrame. If reduce is None (the default), apply's
4839
+ return value will be guessed by calling func an empty Series (note:
4840
+ while guessing, exceptions raised by func will be ignored). If
4841
+ reduce is True a Series will always be returned, and if False a
4842
+ DataFrame will always be returned.
4843
+ args : tuple
4844
+ Positional arguments to pass to function in addition to the
4845
+ array/series
4846
+ Additional keyword arguments will be passed as keywords to the function
4854
4847
4855
- Examples
4856
- --------
4857
- >>> df.apply(numpy.sqrt) # returns DataFrame
4858
- >>> df.apply(numpy.sum, axis=0) # equiv to df.sum(0)
4859
- >>> df.apply(numpy.sum, axis=1) # equiv to df.sum(1)
4848
+ Notes
4849
+ -----
4850
+ In the current implementation apply calls func twice on the
4851
+ first column/row to decide whether it can take a fast or slow
4852
+ code path. This can lead to unexpected behavior if func has
4853
+ side-effects, as they will take effect twice for the first
4854
+ column/row.
4860
4855
4861
- See also
4862
- --------
4863
- DataFrame.applymap: For elementwise operations
4864
- DataFrame.aggregate: only perform aggregating type operations
4865
- DataFrame.transform: only perform transformating type operations
4856
+ Examples
4857
+ --------
4858
+ >>> df.apply(numpy.sqrt) # returns DataFrame
4859
+ >>> df.apply(numpy.sum, axis=0) # equiv to df.sum(0)
4860
+ >>> df.apply(numpy.sum, axis=1) # equiv to df.sum(1)
4866
4861
4867
- Returns
4868
- -------
4869
- applied : Series or DataFrame
4870
- """ )
4862
+ See also
4863
+ --------
4864
+ DataFrame.applymap: For elementwise operations
4865
+ DataFrame.aggregate: only perform aggregating type operations
4866
+ DataFrame.transform: only perform transformating type operations
4871
4867
4872
- @Appender (_shared_docs ['apply' ])
4873
- def apply (self , func , axis = 0 , broadcast = False , raw = False , reduce = None ,
4874
- args = (), ** kwds ):
4868
+ Returns
4869
+ -------
4870
+ applied : Series or DataFrame
4871
+ """
4875
4872
from pandas .core .apply import frame_apply
4876
4873
op = frame_apply (self ,
4877
4874
func = func ,
0 commit comments