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

Series.__getitem__ doesn't work when Series is given #1073

Closed
harupy opened this issue Nov 25, 2019 · 2 comments · Fixed by #1075
Closed

Series.__getitem__ doesn't work when Series is given #1073

harupy opened this issue Nov 25, 2019 · 2 comments · Fixed by #1075

Comments

@harupy
Copy link
Contributor

harupy commented Nov 25, 2019

import pandas as pd
from databricks import koalas as ks

pser = pd.Series([1, 2, 3])

>>> pser[pser == 1]
0    1
dtype: int64

kser = ks.from_pandas(pser)

>>> kser[kser == 1]

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/harutaka/.pyenv/versions/anaconda3-5.3.1/envs/kp-dev-env/lib/python3.6/site-packages/databricks/koalas/series.py", line 4188, in __getitem__
    for level, index in enumerate(key)]
  File "/Users/harutaka/.pyenv/versions/anaconda3-5.3.1/envs/kp-dev-env/lib/python3.6/site-packages/databricks/koalas/series.py", line 4188, in <listcomp>
    for level, index in enumerate(key)]
  File "/Users/harutaka/.pyenv/versions/anaconda3-5.3.1/envs/kp-dev-env/lib/python3.6/site-packages/pyspark/sql/column.py", line 115, in _
    njc = getattr(self._jc, name)(jc)
  File "/Users/harutaka/.pyenv/versions/anaconda3-5.3.1/envs/kp-dev-env/lib/python3.6/site-packages/py4j/java_gateway.py", line 1248, in __call__
    args_command, temp_args = self._build_args(*args)
  File "/Users/harutaka/.pyenv/versions/anaconda3-5.3.1/envs/kp-dev-env/lib/python3.6/site-packages/py4j/java_gateway.py", line 1212, in _build_args
    (new_args, temp_args) = self._get_args(args)
  File "/Users/harutaka/.pyenv/versions/anaconda3-5.3.1/envs/kp-dev-env/lib/python3.6/site-packages/py4j/java_gateway.py", line 1199, in _get_args
    temp_arg = converter.convert(arg, self.gateway_client)
  File "/Users/harutaka/.pyenv/versions/anaconda3-5.3.1/envs/kp-dev-env/lib/python3.6/site-packages/py4j/java_collections.py", line 512, in convert
    for key in object.keys():
  File "/Users/harutaka/.pyenv/versions/anaconda3-5.3.1/envs/kp-dev-env/lib/python3.6/site-packages/databricks/koalas/indexes.py", line 492, in __iter__
    return _MissingPandasLikeIndex.__iter__(self)
  File "/Users/harutaka/.pyenv/versions/anaconda3-5.3.1/envs/kp-dev-env/lib/python3.6/site-packages/databricks/koalas/missing/__init__.py", line 24, in unsupported_function
    reason=reason)
databricks.koalas.exceptions.PandasNotImplementedError: The method `pd.Index.__iter__()` is not implemented. If you want to collect your data as an NumPy array, use 'to_numpy()' instead.
@guyao
Copy link
Contributor

guyao commented Nov 25, 2019

I found one comment about the concern of implementing __iter__
#1003 (comment)

But personally it is not ideal way to raise this kind of exception.
🤔

@harupy
Copy link
Contributor Author

harupy commented Nov 26, 2019

@guyao the issue is Series.getitem is not expected to take Series. I created a PR to address this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants