# Buggy code
def groupby_bins(
    self,
    group,
    bins,
    right=True,
    labels=None,
    precision=3,
    include_lowest=False,
    squeeze=True,
):
    """Returns a GroupBy object for performing grouped operations.

    Rather than using all unique values of `group`, the values are discretized
    first by applying `pandas.cut` [1]_ to `group`.

    Parameters
    ----------
    group : str, DataArray or IndexVariable
        Array whose binned values should be used to group this array. If a
        string, must be the name of a variable contained in this dataset.
    bins : int or array of scalars
        If bins is an int, it defines the number of equal-width bins in the
        range of x. However, in this case, the range of x is extended by .1%
        on each side to include the min or max values of x. If bins is a
        sequence it defines the bin edges allowing for non-uniform bin
        width. No extension of the range of x is done in this case.
    right : boolean, optional
        Indicates whether the bins include the rightmost edge or not. If
        right == True (the default), then the bins [1,2,3,4] indicate
        (1,2], (2,3], (3,4].
    labels : array or boolean, default None
        Used as labels for the resulting bins. Must be of the same length as
        the resulting bins. If False, string bin labels are assigned by
        `pandas.cut`.
    precision : int
        The precision at which to store and display the bins labels.
    include_lowest : bool
        Whether the first interval should be left-inclusive or not.
    squeeze : boolean, optional
        If "group" is a dimension of any arrays in this dataset, `squeeze`
        controls whether the subarrays have a dimension of length 1 along
        that dimension or if the dimension is squeezed out.

    Returns
    -------
    grouped : GroupBy
        A `GroupBy` object patterned after `pandas.GroupBy` that can be
        iterated over in the form of `(unique_value, grouped_array)` pairs.
        The name of the group has the added suffix `_bins` in order to
        distinguish it from the original variable.

    References
    ----------
    .. [1] http://pandas.pydata.org/pandas-docs/stable/generated/pandas.cut.html
    """
    return self.groupby_cls(
        self,
        group,
        squeeze=squeeze,
        bins=bins,
        cut_kwargs={
            "right": right,
            "labels": labels,
            "precision": precision,
            "include_lowest": include_lowest,
        },
    )


# Traceback (AttributeError)
In [13]: xr.DataArray(np.random.rand(10,3)).to_dataset('dim_1').rolling
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-13-438d3638a0d0> in <module>()
----> 1 xr.DataArray(np.random.rand(10,3)).to_dataset('dim_1').rolling

/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/xarray/core/common.py in __getattr__(self, name)
135                     return source[name]
136         raise AttributeError("%r object has no attribute %r" %
--> 137                              (type(self).__name__, name))
138
139     def __setattr__(self, name, value):

AttributeError: 'Dataset' object has no attribute 'rolling'

# Fixed code
def groupby_bins(
    self,
    group,
    bins,
    right=True,
    labels=None,
    precision=3,
    include_lowest=False,
    squeeze=True,
):
    """Returns a GroupBy object for performing grouped operations.

    Rather than using all unique values of `group`, the values are discretized
    first by applying `pandas.cut` [1]_ to `group`.

    Parameters
    ----------
    group : str, DataArray or IndexVariable
        Array whose binned values should be used to group this array. If a
        string, must be the name of a variable contained in this dataset.
    bins : int or array of scalars
        If bins is an int, it defines the number of equal-width bins in the
        range of x. However, in this case, the range of x is extended by .1%
        on each side to include the min or max values of x. If bins is a
        sequence it defines the bin edges allowing for non-uniform bin
        width. No extension of the range of x is done in this case.
    right : boolean, optional
        Indicates whether the bins include the rightmost edge or not. If
        right == True (the default), then the bins [1,2,3,4] indicate
        (1,2], (2,3], (3,4].
    labels : array or boolean, default None
        Used as labels for the resulting bins. Must be of the same length as
        the resulting bins. If False, string bin labels are assigned by
        `pandas.cut`.
    precision : int
        The precision at which to store and display the bins labels.
    include_lowest : bool
        Whether the first interval should be left-inclusive or not.
    squeeze : boolean, optional
        If "group" is a dimension of any arrays in this dataset, `squeeze`
        controls whether the subarrays have a dimension of length 1 along
        that dimension or if the dimension is squeezed out.

    Returns
    -------
    grouped : GroupBy
        A `GroupBy` object patterned after `pandas.GroupBy` that can be
        iterated over in the form of `(unique_value, grouped_array)` pairs.
        The name of the group has the added suffix `_bins` in order to
        distinguish it from the original variable.

    References
    ----------
    .. [1] http://pandas.pydata.org/pandas-docs/stable/generated/pandas.cut.html
    """
    return self._groupby_cls(
        self,
        group,
        squeeze=squeeze,
        bins=bins,
        cut_kwargs={
            "right": right,
            "labels": labels,
            "precision": precision,
            "include_lowest": include_lowest,
        },
    )