# Buggy code
def add_prefix(self, prefix):
    """
    Prefix labels with string `prefix`.

    For Series, the row labels are prefixed.
    For DataFrame, the column labels are prefixed.

    Parameters
    ----------
    prefix : str
       The string to add before each label.

    Returns
    -------
    DataFrame
       New DataFrame with updated labels.

    See Also
    --------
    Series.add_prefix: Prefix row labels with string `prefix`.
    Series.add_suffix: Suffix row labels with string `suffix`.
    DataFrame.add_suffix: Suffix column labels with string `suffix`.

    Examples
    --------
    >>> df = ks.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]}, columns=['A', 'B'])
    >>> df
       A  B
    0  1  3
    1  2  4
    2  3  5
    3  4  6

    >>> df.add_prefix('col_')
       col_A  col_B
    0      1      3
    1      2      4
    2      3      5
    3      4      6
    """
    assert isinstance(prefix, str)
    data_columns = self._internal.data_columns

    sdf = self._sdf.select(
        self._internal.index_columns
        + [self[name]._scol.alias(prefix + name) for name in data_columns]
    )
    internal = self._internal.copy(
        sdf=sdf, data_columns=[prefix + name for name in data_columns]
    )
    return DataFrame(internal)


# 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 add_prefix(self, prefix):
    """
    Prefix labels with string `prefix`.

    For Series, the row labels are prefixed.
    For DataFrame, the column labels are prefixed.

    Parameters
    ----------
    prefix : str
       The string to add before each label.

    Returns
    -------
    DataFrame
       New DataFrame with updated labels.

    See Also
    --------
    Series.add_prefix: Prefix row labels with string `prefix`.
    Series.add_suffix: Suffix row labels with string `suffix`.
    DataFrame.add_suffix: Suffix column labels with string `suffix`.

    Examples
    --------
    >>> df = ks.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]}, columns=['A', 'B'])
    >>> df
       A  B
    0  1  3
    1  2  4
    2  3  5
    3  4  6

    >>> df.add_prefix('col_')
       col_A  col_B
    0      1      3
    1      2      4
    2      3      5
    3      4      6
    """
    assert isinstance(prefix, str)
    data_columns = self._internal.data_columns

    sdf = self._sdf.select(
        self._internal.index_scols
        + [self._internal.scol_for(name).alias(prefix + name) for name in data_columns]
    )
    internal = self._internal.copy(
        sdf=sdf, data_columns=[prefix + name for name in data_columns]
    )
    return DataFrame(internal)