Skip to content

Commit

Permalink
Avoid unnecessary Spark job and DataFrame creation
Browse files Browse the repository at this point in the history
  • Loading branch information
floscha committed May 27, 2019
1 parent a61f163 commit 2dc8fa5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions databricks/koalas/indexing.py
Expand Up @@ -142,13 +142,14 @@ def __getitem__(self, key):
series = self._ks if self._ks is not None else self._kdf[column]

row = key[0]
sdf = (series._kdf._sdf
pdf = (series._kdf._sdf
.where(F.col(self._kdf._metadata.index_columns[0]) == row)
.select(column))
if sdf.count() < 1:
.select(column)
.toPandas())
if len(pdf) < 1:
raise KeyError("'%s" % row)

values = DataFrame(sdf).to_pandas().iloc[:, 0].values
values = pdf.iloc[:, 0].values
return values[0] if len(values) == 1 else values


Expand Down

0 comments on commit 2dc8fa5

Please sign in to comment.