Skip to content

Commit

Permalink
Fix Series.item to run a Spark job once (#1518)
Browse files Browse the repository at this point in the history
According to the comment #1502 (comment), fixed `Series.item` to run a Spark job not twice, once.
  • Loading branch information
itholic committed May 21, 2020
1 parent eb4d21c commit bdd34ed
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions databricks/koalas/series.py
Expand Up @@ -4873,10 +4873,7 @@ def item(self):
>>> kser.item()
10
"""
item_top_two = self[:2]
if len(item_top_two) != 1:
raise ValueError("can only convert an array of size 1 to a Python scalar")
return item_top_two[0]
return self.head(2).to_pandas().item()

def _cum(self, func, skipna, part_cols=()):
# This is used to cummin, cummax, cumsum, etc.
Expand Down

0 comments on commit bdd34ed

Please sign in to comment.