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

Support operations between Series and Index. #1996

Merged
merged 4 commits into from
Jan 12, 2021

Conversation

ueshin
Copy link
Collaborator

@ueshin ueshin commented Jan 8, 2021

Supports operations between Series and Index.

>>> kser = ks.Series([1, 2, 3, 4, 5, 6, 7])
>>> kidx = ks.Index([0, 1, 2, 3, 4, 5, 6])

>>> (kser + 1 + 10 * kidx).sort_index()
0     2
1    13
2    24
3    35
4    46
5    57
6    68
dtype: int64
>>> (kidx + 1 + 10 * kser).sort_index()
0    11
1    22
2    33
3    44
4    55
5    66
6    77
dtype: int64

@codecov-io
Copy link

codecov-io commented Jan 8, 2021

Codecov Report

Merging #1996 (62190aa) into master (ddbdc9a) will decrease coverage by 1.56%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1996      +/-   ##
==========================================
- Coverage   94.51%   92.94%   -1.57%     
==========================================
  Files          50       50              
  Lines       10965    10878      -87     
==========================================
- Hits        10364    10111     -253     
- Misses        601      767     +166     
Impacted Files Coverage Δ
databricks/koalas/utils.py 94.83% <ø> (-0.54%) ⬇️
databricks/koalas/base.py 97.25% <100.00%> (+0.86%) ⬆️
databricks/koalas/indexes.py 96.68% <100.00%> (+0.06%) ⬆️
databricks/koalas/series.py 96.62% <100.00%> (-0.13%) ⬇️
databricks/koalas/usage_logging/__init__.py 25.66% <0.00%> (-66.65%) ⬇️
databricks/koalas/usage_logging/usage_logger.py 47.82% <0.00%> (-52.18%) ⬇️
databricks/koalas/__init__.py 79.68% <0.00%> (-10.94%) ⬇️
databricks/koalas/accessors.py 86.43% <0.00%> (-7.04%) ⬇️
databricks/conftest.py 93.22% <0.00%> (-6.78%) ⬇️
databricks/koalas/namespace.py 79.58% <0.00%> (-4.62%) ⬇️
... and 22 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ddbdc9a...62190aa. Read the comment docs.

@ueshin ueshin marked this pull request as ready for review January 8, 2021 02:47
@ueshin ueshin marked this pull request as draft January 8, 2021 21:23
@ueshin ueshin marked this pull request as ready for review January 8, 2021 22:13
@HyukjinKwon
Copy link
Member

Looks fine otherwise

else:
index_ops = self._align_and_column_op(f, *args)
raise ValueError(ERROR_MESSAGE_CANNOT_COMBINE)

if not all(self.name == col.name for col in cols):
index_ops = index_ops.rename(None)
Copy link
Contributor

@xinrong-meng xinrong-meng Jan 11, 2021

Choose a reason for hiding this comment

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

I am wondering whether index_ops's name should always be None for operations between Series and Index.

Copy link
Contributor

Choose a reason for hiding this comment

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

And I may have some concern about what index_ops means. It seems to be the result we return finally.

Copy link
Contributor

Choose a reason for hiding this comment

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

@xinrong-databricks When the name is same, seems they keep it in pandas.

>>> pd.Series([1, 2, 3], name="Koalas") + pd.Index([2, 3, 4], name="Koalas")
0    3
1    5
2    7
Name: Koalas, dtype: int64

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, thanks!

@ueshin
Copy link
Collaborator Author

ueshin commented Jan 12, 2021

Thanks! merging.

@ueshin ueshin merged commit 8d4157d into databricks:master Jan 12, 2021
@ueshin ueshin deleted the ops_series_index branch January 12, 2021 18:45
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.

5 participants