databricks / koalas

Koalas: pandas API on Apache Spark

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support bool list-like object for column selection in `loc` indexer.

ueshin opened this issue · comments

We should support bool list-like object for loc indexer.

>>> df
     a    b
0  1.0  NaN
1  2.0  1.0
2  NaN  NaN
>>> df.columns.str.contains("a", regex=True)
array([ True, False])
>>> df.loc[:, df.columns.str.contains("a", regex=True)]
Traceback (most recent call last):
...
KeyError: "['True'] not in index"

whereas:

>>> pdf.loc[:, pdf.columns.str.contains("a", regex=True)]
     a
0  1.0
1  2.0
2  NaN

See also: #2043 (comment)