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

Fixed ks.Index.to_series() to work properly with name paramter #1643

Merged
merged 4 commits into from
Jul 16, 2020

Conversation

itholic
Copy link
Contributor

@itholic itholic commented Jul 9, 2020

The existing ks.Index.to_series() work not properly with name parameter
(Although Its test was passed !)

>>> kidx = ks.Index([1, 2, 3])
>>> kidx.to_series(name="Koalas")
1    1
2    2
3    3
Name: 0, dtype: int64  # It should have renamed to 'Koalas'

This PR addressed it.

@itholic
Copy link
Contributor Author

itholic commented Jul 9, 2020

The existing test code below has been passing even though the name was not changed properly.

self.assert_eq(kidx.to_series(name="a"), pidx.to_series(name="a"))
>>> kidx.to_series(name="a")
0    0
1    1
3    3
5    5
6    6
8    8
9    9
9    9
9    9
Name: 0, dtype: int64

>>> pidx.to_series(name="a")
0    0
1    1
3    3
5    5
6    6
8    8
9    9
9    9
9    9
Name: a, dtype: int64

For now, I addressed it with repr, but maybe I think we'd better to find the better solution ?

@ueshin
Copy link
Collaborator

ueshin commented Jul 9, 2020

What if ks.Index([1, 2, 3], name=‘a’).to_series() ?

@itholic
Copy link
Contributor Author

itholic commented Jul 9, 2020

What if ks.Index([1, 2, 3], name=‘a’).to_series() ?

Oh, I think we should manage it, too.

Just addressed it, Thanks! :)

FYI:

>>> pd.Index([1, 2, 3], name="a").to_series()  # example of pandas
a
1    1
2    2
3    3
Name: a, dtype: int64

>>> ks.Index([1, 2, 3], name="a").to_series()  # example of Koalas
a
1    1
2    2
3    3
Name: 0, dtype: int64  # TODO: the name of Series also should be "a" which is the same name with index

@itholic
Copy link
Contributor Author

itholic commented Jul 9, 2020

@ueshin

Anyway, could you help me to solve this mypy failure when you available ?
Since I'm not familiar with mypy that much, couldn't find the solution yet. 😿

databricks/koalas/indexes.py Outdated Show resolved Hide resolved
databricks/koalas/tests/test_indexes.py Show resolved Hide resolved
Copy link
Collaborator

@ueshin ueshin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, LGTM.

databricks/koalas/tests/test_indexes.py Show resolved Hide resolved
databricks/koalas/indexes.py Show resolved Hide resolved
@HyukjinKwon HyukjinKwon merged commit 70d4348 into databricks:master Jul 16, 2020
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 this pull request may close these issues.

3 participants