def diff(self, periods: int=1, axis: Axis=0) -> 'DataFrame':
    "\n        First discrete difference of element.\n\n        Calculates the difference of a DataFrame element compared with another element in the\n        DataFrame (default is the element in the same column of the previous row).\n\n        .. note:: the current implementation of diff uses Spark's Window without\n            specifying partition specification. This leads to move all data into\n            single partition in single machine and could cause serious\n            performance degradation. Avoid this method against very large dataset.\n\n        Parameters\n        ----------\n        periods : int, default 1\n            Periods to shift for calculating difference, accepts negative values.\n        axis : int, default 0 or 'index'\n            Can only be set to 0 at the moment.\n\n        Returns\n        -------\n        diffed : DataFrame\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({'a': [1, 2, 3, 4, 5, 6],\n        ...                    'b': [1, 1, 2, 3, 5, 8],\n        ...                    'c': [1, 4, 9, 16, 25, 36]}, columns=['a', 'b', 'c'])\n        >>> df\n           a  b   c\n        0  1  1   1\n        1  2  1   4\n        2  3  2   9\n        3  4  3  16\n        4  5  5  25\n        5  6  8  36\n\n        >>> df.diff()\n             a    b     c\n        0  NaN  NaN   NaN\n        1  1.0  0.0   3.0\n        2  1.0  1.0   5.0\n        3  1.0  1.0   7.0\n        4  1.0  2.0   9.0\n        5  1.0  3.0  11.0\n\n        Difference with previous column\n\n        >>> df.diff(periods=3)\n             a    b     c\n        0  NaN  NaN   NaN\n        1  NaN  NaN   NaN\n        2  NaN  NaN   NaN\n        3  3.0  2.0  15.0\n        4  3.0  4.0  21.0\n        5  3.0  6.0  27.0\n\n        Difference with following row\n\n        >>> df.diff(periods=-1)\n             a    b     c\n        0 -1.0  0.0  -3.0\n        1 -1.0 -1.0  -5.0\n        2 -1.0 -1.0  -7.0\n        3 -1.0 -2.0  -9.0\n        4 -1.0 -3.0 -11.0\n        5  NaN  NaN   NaN\n        "
    axis = validate_axis(axis)
    if (axis != 0):
        raise NotImplementedError('axis should be either 0 or "index" currently.')
    return self._apply_series_op((lambda psser: psser._diff(periods)), should_resolve=True)
First discrete difference of element.

Calculates the difference of a DataFrame element compared with another element in the
DataFrame (default is the element in the same column of the previous row).

.. note:: the current implementation of diff uses Spark's Window without
    specifying partition specification. This leads to move all data into
    single partition in single machine and could cause serious
    performance degradation. Avoid this method against very large dataset.

Parameters
----------
periods : int, default 1
    Periods to shift for calculating difference, accepts negative values.
axis : int, default 0 or 'index'
    Can only be set to 0 at the moment.

Returns
-------
diffed : DataFrame

Examples
--------
>>> df = ps.DataFrame({'a': [1, 2, 3, 4, 5, 6],
...                    'b': [1, 1, 2, 3, 5, 8],
...                    'c': [1, 4, 9, 16, 25, 36]}, columns=['a', 'b', 'c'])
>>> df
   a  b   c
0  1  1   1
1  2  1   4
2  3  2   9
3  4  3  16
4  5  5  25
5  6  8  36

>>> df.diff()
     a    b     c
0  NaN  NaN   NaN
1  1.0  0.0   3.0
2  1.0  1.0   5.0
3  1.0  1.0   7.0
4  1.0  2.0   9.0
5  1.0  3.0  11.0

Difference with previous column

>>> df.diff(periods=3)
     a    b     c
0  NaN  NaN   NaN
1  NaN  NaN   NaN
2  NaN  NaN   NaN
3  3.0  2.0  15.0
4  3.0  4.0  21.0
5  3.0  6.0  27.0

Difference with following row

>>> df.diff(periods=-1)
     a    b     c
0 -1.0  0.0  -3.0
1 -1.0 -1.0  -5.0
2 -1.0 -1.0  -7.0
3 -1.0 -2.0  -9.0
4 -1.0 -3.0 -11.0
5  NaN  NaN   NaN
def diff(self, periods: int=1, axis: Axis=0) -> 'DataFrame':
    "\n        First discrete difference of element.\n\n        Calculates the difference of a DataFrame element compared with another element in the\n        DataFrame (default is the element in the same column of the previous row).\n\n        .. note:: the current implementation of diff uses Spark's Window without\n            specifying partition specification. This leads to move all data into\n            single partition in single machine and could cause serious\n            performance degradation. Avoid this method against very large dataset.\n\n        Parameters\n        ----------\n        periods : int, default 1\n            Periods to shift for calculating difference, accepts negative values.\n        axis : int, default 0 or 'index'\n            Can only be set to 0 at the moment.\n\n        Returns\n        -------\n        diffed : DataFrame\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({'a': [1, 2, 3, 4, 5, 6],\n        ...                    'b': [1, 1, 2, 3, 5, 8],\n        ...                    'c': [1, 4, 9, 16, 25, 36]}, columns=['a', 'b', 'c'])\n        >>> df\n           a  b   c\n        0  1  1   1\n        1  2  1   4\n        2  3  2   9\n        3  4  3  16\n        4  5  5  25\n        5  6  8  36\n\n        >>> df.diff()\n             a    b     c\n        0  NaN  NaN   NaN\n        1  1.0  0.0   3.0\n        2  1.0  1.0   5.0\n        3  1.0  1.0   7.0\n        4  1.0  2.0   9.0\n        5  1.0  3.0  11.0\n\n        Difference with previous column\n\n        >>> df.diff(periods=3)\n             a    b     c\n        0  NaN  NaN   NaN\n        1  NaN  NaN   NaN\n        2  NaN  NaN   NaN\n        3  3.0  2.0  15.0\n        4  3.0  4.0  21.0\n        5  3.0  6.0  27.0\n\n        Difference with following row\n\n        >>> df.diff(periods=-1)\n             a    b     c\n        0 -1.0  0.0  -3.0\n        1 -1.0 -1.0  -5.0\n        2 -1.0 -1.0  -7.0\n        3 -1.0 -2.0  -9.0\n        4 -1.0 -3.0 -11.0\n        5  NaN  NaN   NaN\n        "
    axis = validate_axis(axis)
    if (axis != 0):
        raise NotImplementedError('axis should be either 0 or "index" currently.')
    return self._apply_series_op((lambda psser: psser._diff(periods)), should_resolve=True)