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 DatetimeIndex.round(), DatetimeIndex.floor(), and DatetimeIndex.ceil() #2082

Merged

Conversation

xinrong-meng
Copy link
Contributor

@xinrong-meng xinrong-meng commented Mar 4, 2021

        >>> rng = ks.date_range('1/1/2018 11:59:00', periods=3, freq='min')

        >>> rng
        DatetimeIndex(['2018-01-01 11:59:00', '2018-01-01 12:00:00',
                       '2018-01-01 12:01:00'],
                      dtype='datetime64[ns]', freq=None)

        >>> rng.round("H")
        DatetimeIndex(['2018-01-01 12:00:00', '2018-01-01 12:00:00',
                       '2018-01-01 12:00:00'],
                      dtype='datetime64[ns]', freq=None)

        >>> rng.floor("H")
        DatetimeIndex(['2018-01-01 11:00:00', '2018-01-01 12:00:00',
                       '2018-01-01 12:00:00'],
                      dtype='datetime64[ns]', freq=None)

        >>> rng.ceil('H')
        DatetimeIndex(['2018-01-01 12:00:00', '2018-01-01 12:00:00',
                       '2018-01-01 13:00:00'],
                      dtype='datetime64[ns]', freq=None)

@codecov-io
Copy link

Codecov Report

Merging #2082 (0de8fe1) into master (9150ca4) will decrease coverage by 5.51%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2082      +/-   ##
==========================================
- Coverage   95.27%   89.76%   -5.52%     
==========================================
  Files          57       57              
  Lines       13196    13107      -89     
==========================================
- Hits        12573    11765     -808     
- Misses        623     1342     +719     
Impacted Files Coverage Δ
databricks/koalas/missing/indexes.py 100.00% <ø> (ø)
databricks/koalas/indexes/datetimes.py 96.58% <100.00%> (-1.52%) ⬇️
databricks/koalas/tests/indexes/test_datetime.py 96.66% <100.00%> (-3.34%) ⬇️
databricks/koalas/plot/plotly.py 15.78% <0.00%> (-81.06%) ⬇️
...bricks/koalas/tests/plot/test_frame_plot_plotly.py 23.33% <0.00%> (-76.67%) ⬇️
...ricks/koalas/tests/plot/test_series_plot_plotly.py 26.92% <0.00%> (-71.26%) ⬇️
databricks/koalas/usage_logging/__init__.py 27.58% <0.00%> (-64.92%) ⬇️
databricks/koalas/usage_logging/usage_logger.py 47.82% <0.00%> (-52.18%) ⬇️
databricks/koalas/typedef/typehints.py 65.92% <0.00%> (-28.50%) ⬇️
databricks/koalas/__init__.py 77.33% <0.00%> (-14.67%) ⬇️
... and 28 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 9150ca4...0de8fe1. Read the comment docs.

@xinrong-meng xinrong-meng requested a review from ueshin March 4, 2021 22:12
Copy link
Contributor

@itholic itholic 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.

# Methods
def ceil(self, freq, *args, **kwargs) -> "DatetimeIndex":
"""
Perform floor operation on the data to the specified freq.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: floor -> ceil ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Thanks!

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.

LGTM.

@ueshin
Copy link
Collaborator

ueshin commented Mar 5, 2021

Thanks! merging.

@ueshin ueshin merged commit 2e6094b into databricks:master Mar 5, 2021
@xinrong-meng
Copy link
Contributor Author

Thank you!

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