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

Implement Series.truncate #928

Merged
merged 8 commits into from
Oct 24, 2019
Merged

Conversation

itholic
Copy link
Contributor

@itholic itholic commented Oct 15, 2019

Like pandas Series.truncate (https://pandas.pydata.org/pandas-docs/version/0.21/generated/pandas.Series.truncate.html#pandas.Series.truncate)

implemented function truncate for Series.

>>> s = ks.Series([10, 20, 30, 40, 50, 60, 70],
...               index=[1, 2, 3, 4, 5, 6, 7])
>>> s
1    10
2    20
3    30
4    40
5    50
6    60
7    70
Name: 0, dtype: int64

>>> s.truncate(2, 5)
2    20
3    30
4    40
5    50
Name: 0, dtype: int64

>>> s = ks.Series([10, 20, 30, 40, 50, 60, 70],
...               index=['a', 'b', 'c', 'd', 'e', 'f', 'g'])
>>> s
a    10
b    20
c    30
d    40
e    50
f    60
g    70
Name: 0, dtype: int64

>>> s.truncate('b', 'e')
b    20
c    30
d    40
e    50
Name: 0, dtype: int64

@codecov-io
Copy link

codecov-io commented Oct 15, 2019

Codecov Report

Merging #928 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #928      +/-   ##
=========================================
+ Coverage   94.49%   94.5%   +0.01%     
=========================================
  Files          34      34              
  Lines        6434    6447      +13     
=========================================
+ Hits         6080    6093      +13     
  Misses        354     354
Impacted Files Coverage Δ
databricks/koalas/missing/series.py 100% <ø> (ø) ⬆️
databricks/koalas/series.py 96% <100%> (+0.08%) ⬆️

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 a924df6...558d978. Read the comment docs.

e 50
Name: 0, dtype: int64
"""
indexes = self.index.to_pandas()
Copy link
Member

Choose a reason for hiding this comment

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

@itholic, this will collect everything in index into driver's memory. We should avoid this.

Copy link
Member

Choose a reason for hiding this comment

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

Koalas index implements is_monotonic_increasing and is_monotonic_decreasing. The problem is that this is an expensive operation as warned in their documentations as it leads all data into single node.

Can you add a note that this API will be expensive (see is_monotonic_increasing as an example). We even might have to explicitly don't implement. cc @ueshin

Copy link
Contributor Author

@itholic itholic Oct 22, 2019

Choose a reason for hiding this comment

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

@HyukjinKwon Thanks for commenting!

yeah you're right. i used is_monotonic_increasing of pandas' because there was a bug for koalas'. (so i fixed in #930 )

now we can use koalas', but there still have an issue about cost as you said.

and first, i wrote note about warning in this API docstring as you said

Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

Looks fine to me. I'll take it back.

@softagram-bot
Copy link

Softagram Impact Report for pull/928 (head commit: 558d978)

⭐ Change Overview

Showing the changed files, dependency changes and the impact - click for full size
(Open in Softagram Desktop for full details)

📄 Full report

Impact Report explained. Give feedback on this report to [email protected]

@HyukjinKwon HyukjinKwon merged commit caac367 into databricks:master Oct 24, 2019
@itholic itholic deleted the s_truncate branch October 24, 2019 04:38
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.

4 participants