Skip to content

ENH: Add milliseconds field support for pd.DateOffset #43598

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

Merged
merged 30 commits into from
Mar 18, 2022

Conversation

isVoid
Copy link
Contributor

@isVoid isVoid commented Sep 16, 2021

@jreback
Copy link
Contributor

jreback commented Sep 16, 2021

you would need tests to prove that this works. We don't currently have support for this. Its possible, but non-trivial to add.

@isVoid
Copy link
Contributor Author

isVoid commented Sep 17, 2021

@jreback - Thanks for pointing this out. I also noticed there isn't a comprehensive test for offset constructions. Looked into https://github.com/pandas-dev/pandas/blob/26064f0f7ea01607a85b399ee4f3de29a864f338/pandas/tests/tseries/offsets/test_offsets.py and https://github.com/pandas-dev/pandas/blob/master/pandas/tests/tslibs/test_liboffsets.py.

I think we might also want to test binops with Timestamp and millisecond.

@isVoid isVoid marked this pull request as ready for review September 29, 2021 16:42
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

you will have to look thru the tests a bit more, but these don't test very much about this, eg. these test some ops, but these barely test that this works.

@isVoid
Copy link
Contributor Author

isVoid commented Oct 5, 2021

@jreback The old TestDateOffset seems lacking comprehensive coverage over the various parameters of DateOffset. I've restructured the class - maintaining the corner cases while extending with more coverage over the parameters and operations. Specifically __add__, __radd__, __rsub__, __mul__ and combination of mul and add.

@jreback
Copy link
Contributor

jreback commented Oct 5, 2021

hmm look near there thought we had another file (but ok if u made comprehensive)

@isVoid
Copy link
Contributor Author

isVoid commented Oct 11, 2021

@jreback , can you point out which file I should look at? I searched around and it looks like each file in offsets/ is very specific to test certain aspect of the offset.

@isVoid
Copy link
Contributor Author

isVoid commented Oct 11, 2021

Also, do you have insights to the current failed tests TestDataFrameSortIndex.test_sort_index_inplace in CI? Seems unrelated to this PR.

@isVoid isVoid requested a review from jreback October 14, 2021 22:25
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

test comment.

can you check if the docs need updating https://pandas.pydata.org/pandas-docs/dev/user_guide/timeseries.html#time-date-components or similar

@jreback
Copy link
Contributor

jreback commented Oct 16, 2021

cc @jbrockmendel if you can have a look.

@isVoid
Copy link
Contributor Author

isVoid commented Oct 20, 2021

can you check if the docs need updating https://pandas.pydata.org/pandas-docs/dev/user_guide/timeseries.html#time-date-components or similar

@jreback I checked that the time-date component still cannot be accessed with addition from this PR. In the DateOffset section below, there's no mentioning of the parameters for the generic DateOffset object. However, I did noticed in this section there's no mentioning of the usage of replacing certain component of the timestamp with DateOffset, and I made a small addition to the paragraph and the example.

@isVoid isVoid requested a review from jbrockmendel December 29, 2021 20:19
@jreback
Copy link
Contributor

jreback commented Jan 16, 2022

@isVoid if you can move the note to 1.5 and merge master

@isVoid
Copy link
Contributor Author

isVoid commented Jan 17, 2022

@jreback done

@jreback
Copy link
Contributor

jreback commented Jan 31, 2022

status here?

@isVoid isVoid requested a review from jbrockmendel January 31, 2022 18:04
@isVoid
Copy link
Contributor Author

isVoid commented Jan 31, 2022

@jreback just responded the most recent review message above. (And applied changes).

@jreback
Copy link
Contributor

jreback commented Mar 6, 2022

@isVoid if you can merge master and get this passing

@isVoid
Copy link
Contributor Author

isVoid commented Mar 7, 2022

@jreback Merged and checks passing.

@isVoid
Copy link
Contributor Author

isVoid commented Mar 8, 2022

@jreback jreback modified the milestones: Contributions Welcome, 1.5 Mar 16, 2022
@jreback
Copy link
Contributor

jreback commented Mar 16, 2022

@isVoid can you merge master

@jreback jreback merged commit 76fa98b into pandas-dev:main Mar 18, 2022
@jreback
Copy link
Contributor

jreback commented Mar 18, 2022

thanks @isVoid for sticking with it!


assert (self.d + DateOffset(months=2)) == datetime(2008, 3, 2)
assert (self.d - DateOffset(months=2)) == datetime(2007, 11, 2)
@pytest.mark.parametrize("relativedelta_kwd", list(liboffsets._relativedelta_kwds))
Copy link
Member

@simonjayhawkins simonjayhawkins Mar 18, 2022

Choose a reason for hiding this comment

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

This needs to be list -> sorted to prevent pytest collection errors with pytest-xdist.

Also, for consistency with elsewhere in this module, could maybe also change "relativedelta_kwd" -> "kwd"?

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

Successfully merging this pull request may close these issues.

BUG: Lacking milliseconds field in DateOffset
5 participants