# Buggy code
def round(self, decimals=0):
    """
    Round a DataFrame to a variable number of decimal places.

    Parameters
    ----------
    decimals : int, dict, Series
        Number of decimal places to round each column to. If an int is
        given, round each column to the same number of places.
        Otherwise dict and Series round to variable numbers of places.
        Column names should be in the keys if `decimals` is a
        dict-like, or in the index if `decimals` is a Series. Any
        columns not included in `decimals` will be left as is. Elements
        of `decimals` which are not columns of the input will be
        ignored.

    Returns
    -------
    DataFrame

    See Also
    --------
    Series.round

    Examples
    --------
    >>> df = ks.DataFrame({'A':[0.028208, 0.038683, 0.877076],
    ...                    'B':[0.992815, 0.645646, 0.149370],
    ...                    'C':[0.173891, 0.577595, 0.491027]},
    ...                    columns=['A', 'B', 'C'],
    ...                    index=['first', 'second', 'third'])
    >>> df
                   A         B         C
    first   0.028208  0.992815  0.173891
    second  0.038683  0.645646  0.577595
    third   0.877076  0.149370  0.491027

    >>> df.round(2)
               A     B     C
    first   0.03  0.99  0.17
    second  0.04  0.65  0.58
    third   0.88  0.15  0.49

    >>> df.round({'A': 1, 'C': 2})
              A         B     C
    first   0.0  0.992815  0.17
    second  0.0  0.645646  0.58
    third   0.9  0.149370  0.49

    >>> decimals = ks.Series([1, 0, 2], index=['A', 'B', 'C'])
    >>> df.round(decimals)
              A    B     C
    first   0.0  1.0  0.17
    second  0.0  1.0  0.58
    third   0.9  0.0  0.49
    """
    if isinstance(decimals, ks.Series):
        decimals_list = [kv for kv in decimals.to_pandas().items()]
    elif isinstance(decimals, dict):
        decimals_list = [(k, v) for k, v in decimals.items()]
    elif isinstance(decimals, int):
        decimals_list = [(v, decimals) for v in self._internal.data_columns]
    else:
        raise ValueError("decimals must be an integer, a dict-like or a Series")

    sdf = self._sdf
    for decimal in decimals_list:
        sdf = sdf.withColumn(decimal[0], F.round(decimal[0], decimal[1]))
    return DataFrame(self._internal.copy(sdf=sdf))


# Traceback (KeyError)
df = ks.read_parquet("/mnt/ivan/sample.parquet")
df['a.b']

# KeyError: 'a.b'
# ---------------------------------------------------------------------------
# KeyError                                  Traceback (most recent call last)
# <command-3188040896828876> in <module>()
#       1 df = ks.read_parquet("/mnt/ivan/sample.parquet")
# ----> 2 df['a.b']
#
# /databricks/python/lib/python3.5/site-packages/databricks/koalas/frame.py in __getitem__(self, key)
#     448
#     449     def __getitem__(self, key):
# --> 450         return self._pd_getitem(key)
#     451
#     452     def __setitem__(self, key, value):
#
# /databricks/python/lib/python3.5/site-packages/databricks/koalas/frame.py in _pd_getitem(self, key)
#     427                 return Series(self._sdf.__getitem__(key), self, self._metadata.index_info)
#     428             except AnalysisException:
# --> 429                 raise KeyError(key)
#     430         if np.isscalar(key) or isinstance(key, (tuple, string_types)):
#     431             raise NotImplementedError(key)
#
# KeyError: 'a.b'

# Fixed code
def round(self, decimals=0):
    """
    Round a DataFrame to a variable number of decimal places.

    Parameters
    ----------
    decimals : int, dict, Series
        Number of decimal places to round each column to. If an int is
        given, round each column to the same number of places.
        Otherwise dict and Series round to variable numbers of places.
        Column names should be in the keys if `decimals` is a
        dict-like, or in the index if `decimals` is a Series. Any
        columns not included in `decimals` will be left as is. Elements
        of `decimals` which are not columns of the input will be
        ignored.

    Returns
    -------
    DataFrame

    See Also
    --------
    Series.round

    Examples
    --------
    >>> df = ks.DataFrame({'A':[0.028208, 0.038683, 0.877076],
    ...                    'B':[0.992815, 0.645646, 0.149370],
    ...                    'C':[0.173891, 0.577595, 0.491027]},
    ...                    columns=['A', 'B', 'C'],
    ...                    index=['first', 'second', 'third'])
    >>> df
                   A         B         C
    first   0.028208  0.992815  0.173891
    second  0.038683  0.645646  0.577595
    third   0.877076  0.149370  0.491027

    >>> df.round(2)
               A     B     C
    first   0.03  0.99  0.17
    second  0.04  0.65  0.58
    third   0.88  0.15  0.49

    >>> df.round({'A': 1, 'C': 2})
              A         B     C
    first   0.0  0.992815  0.17
    second  0.0  0.645646  0.58
    third   0.9  0.149370  0.49

    >>> decimals = ks.Series([1, 0, 2], index=['A', 'B', 'C'])
    >>> df.round(decimals)
              A    B     C
    first   0.0  1.0  0.17
    second  0.0  1.0  0.58
    third   0.9  0.0  0.49
    """
    if isinstance(decimals, ks.Series):
        decimals_list = [kv for kv in decimals.to_pandas().items()]
    elif isinstance(decimals, dict):
        decimals_list = [(k, v) for k, v in decimals.items()]
    elif isinstance(decimals, int):
        decimals_list = [(v, decimals) for v in self._internal.data_columns]
    else:
        raise ValueError("decimals must be an integer, a dict-like or a Series")

    sdf = self._sdf
    for decimal in decimals_list:
        sdf = sdf.withColumn(decimal[0], F.round(scol_for(sdf, decimal[0]), decimal[1]))
    return DataFrame(self._internal.copy(sdf=sdf))