# Buggy code
def _pd_getitem(self, key):
    from databricks.koalas.series import Series

    if key is None:
        raise KeyError("none key")
    if isinstance(key, str):
        try:
            return Series(
                self._internal.copy(scol=self._sdf.__getitem__(key)), anchor=self
            )
        except AnalysisException:
            raise KeyError(key)
    if np.isscalar(key) or isinstance(key, (tuple, str)):
        raise NotImplementedError(key)
    elif isinstance(key, slice):
        return self.loc[key]

    if isinstance(key, (pd.Series, np.ndarray, pd.Index)):
        raise NotImplementedError(key)
    if isinstance(key, list):
        return self.loc[:, key]
    if isinstance(key, DataFrame):
        # TODO Should not implement alignment, too dangerous?
        return Series(self._internal.copy(scol=self._sdf.__getitem__(key)), anchor=self)
    if isinstance(key, Series):
        # TODO Should not implement alignment, too dangerous?
        # It is assumed to be only a filter, otherwise .loc should be used.
        bcol = key._scol.cast("boolean")
        return DataFrame(self._internal.copy(sdf=self._sdf.filter(bcol)))
    raise NotImplementedError(key)


# 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 _pd_getitem(self, key):
    from databricks.koalas.series import Series

    if key is None:
        raise KeyError("none key")
    if isinstance(key, str):
        try:
            return Series(
                self._internal.copy(scol=self._internal.scol_for(key)), anchor=self
            )
        except AnalysisException:
            raise KeyError(key)
    if np.isscalar(key) or isinstance(key, (tuple, str)):
        raise NotImplementedError(key)
    elif isinstance(key, slice):
        return self.loc[key]

    if isinstance(key, (pd.Series, np.ndarray, pd.Index)):
        raise NotImplementedError(key)
    if isinstance(key, list):
        return self.loc[:, key]
    if isinstance(key, DataFrame):
        # TODO Should not implement alignment, too dangerous?
        return Series(
            self._internal.copy(scol=self._internal.scol_for(key)), anchor=self
        )
    if isinstance(key, Series):
        # TODO Should not implement alignment, too dangerous?
        # It is assumed to be only a filter, otherwise .loc should be used.
        bcol = key._scol.cast("boolean")
        return DataFrame(self._internal.copy(sdf=self._sdf.filter(bcol)))
    raise NotImplementedError(key)