@@ -2751,40 +2751,12 @@ def cov(
27512751 this_values , other_values , min_periods = min_periods , ddof = ddof
27522752 )
27532753
2754- def diff (self , periods : int = 1 ) -> Series :
2755- """
2756- First discrete difference of element.
2757-
2758- Calculates the difference of a Series element compared with another
2759- element in the Series (default is element in previous row).
2760-
2761- Parameters
2762- ----------
2763- periods : int, default 1
2764- Periods to shift for calculating difference, accepts negative
2765- values.
2766-
2767- Returns
2768- -------
2769- Series
2770- First differences of the Series.
2771-
2772- See Also
2773- --------
2774- Series.pct_change: Percent change over given number of periods.
2775- Series.shift: Shift index by desired number of periods with an
2776- optional time freq.
2777- DataFrame.diff: First discrete difference of object.
2778-
2779- Notes
2780- -----
2781- For boolean dtypes, this uses :meth:`operator.xor` rather than
2782- :meth:`operator.sub`.
2783- The result is calculated according to current dtype in {klass},
2784- however dtype of the result is always float64.
2785-
2786- Examples
2787- --------
2754+ @doc (
2755+ klass = "Series" ,
2756+ extra_params = "" ,
2757+ other_klass = "DataFrame" ,
2758+ examples = dedent (
2759+ """
27882760 Difference with previous row
27892761
27902762 >>> s = pd.Series([1, 1, 2, 3, 5, 8])
@@ -2825,7 +2797,44 @@ def diff(self, periods: int = 1) -> Series:
28252797 >>> s.diff()
28262798 0 NaN
28272799 1 255.0
2828- dtype: float64
2800+ dtype: float64"""
2801+ ),
2802+ )
2803+ def diff (self , periods : int = 1 ) -> Series :
2804+ """
2805+ First discrete difference of element.
2806+
2807+ Calculates the difference of a {klass} element compared with another
2808+ element in the {klass} (default is element in previous row).
2809+
2810+ Parameters
2811+ ----------
2812+ periods : int, default 1
2813+ Periods to shift for calculating difference, accepts negative
2814+ values.
2815+ {extra_params}
2816+ Returns
2817+ -------
2818+ {klass}
2819+ First differences of the Series.
2820+
2821+ See Also
2822+ --------
2823+ {klass}.pct_change: Percent change over given number of periods.
2824+ {klass}.shift: Shift index by desired number of periods with an
2825+ optional time freq.
2826+ {other_klass}.diff: First discrete difference of object.
2827+
2828+ Notes
2829+ -----
2830+ For boolean dtypes, this uses :meth:`operator.xor` rather than
2831+ :meth:`operator.sub`.
2832+ The result is calculated according to current dtype in {klass},
2833+ however dtype of the result is always float64.
2834+
2835+ Examples
2836+ --------
2837+ {examples}
28292838 """
28302839 if not lib .is_integer (periods ):
28312840 if not (is_float (periods ) and periods .is_integer ()):
0 commit comments