Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to_list work properly in pandas < 0.24 #1823

Merged
merged 2 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion databricks/koalas/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,11 @@ def to_list(self):
to be small, as all the data is loaded into the driver's memory.

"""
return self._to_internal_pandas().to_list()
# pandas<0.24 doesn't support `to_list()` as an alias for `tolist()`
if LooseVersion(pd.__version__) < LooseVersion("0.24"):
return self._to_internal_pandas().tolist()
else:
return self._to_internal_pandas().to_list()

tolist = to_list

Expand Down
4 changes: 3 additions & 1 deletion databricks/koalas/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,9 @@ def test_is_unique(self):

def test_to_list(self):
if LooseVersion(pd.__version__) >= LooseVersion("0.24.0"):
self.assertEqual(self.kser.to_list(), self.pser.to_list())
self.assert_eq(self.kser.to_list(), self.pser.to_list())
else:
self.assert_eq(self.kser.tolist(), self.pser.tolist())

def test_append(self):
pser1 = pd.Series([1, 2, 3], name="0")
Expand Down