Skip to content

BUG: Period[us] start_time off by 1 nanosecond #31475

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 9 commits into from
Feb 4, 2020

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

@jbrockmendel
Copy link
Member Author

jbrockmendel commented Jan 31, 2020

Updated to catch overflow correctly.

@jbrockmendel jbrockmendel reopened this Jan 31, 2020
@jreback jreback added Bug Period Period data type labels Jan 31, 2020
@@ -656,6 +656,23 @@ def test_conv_secondly(self):

assert ival_S.asfreq("S") == ival_S

def test_conv_microsecond(self):
# Avoid floating point errors dropping the start_time to before
# the beginning of the Period
Copy link
Member

@gfyoung gfyoung Jan 31, 2020

Choose a reason for hiding this comment

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

Changes look good, whatsnew entry notwithstanding.

Reference the PR number (since there is no issue number) here.

@@ -1186,6 +1186,13 @@ cdef int64_t period_ordinal_to_dt64(int64_t ordinal, int freq) except? -1:
if ordinal == NPY_NAT:
return NPY_NAT

if freq == 11000:
# Microsecond, avoid get_date_info to prevent floating point errors
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to fix get_date_info instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe. My first two tries didnt work.

Copy link
Contributor

Choose a reason for hiding this comment

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

so, is it possible to use this path for all freqs?

Copy link
Member Author

Choose a reason for hiding this comment

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

definitely not for the lower-frequency freqs because of their to_end attrs e.g. Q-DEC, Q-NOV.

@@ -1186,6 +1186,13 @@ cdef int64_t period_ordinal_to_dt64(int64_t ordinal, int freq) except? -1:
if ordinal == NPY_NAT:
return NPY_NAT

if freq == 11000:
# Microsecond, avoid get_date_info to prevent floating point errors
Copy link
Contributor

Choose a reason for hiding this comment

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

so, is it possible to use this path for all freqs?

@@ -1186,6 +1186,13 @@ cdef int64_t period_ordinal_to_dt64(int64_t ordinal, int freq) except? -1:
if ordinal == NPY_NAT:
return NPY_NAT

if freq == 11000:
# Microsecond, avoid get_date_info to prevent floating point errors
pandas_datetime_to_datetimestruct(ordinal, NPY_FR_us, &dts)
Copy link
Contributor

Choose a reason for hiding this comment

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

if this path is kept, then I would do if/else here and have: L 1192, L1194 after (as they are repeated at L1197, 1198)

Copy link
Member Author

Choose a reason for hiding this comment

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

will do

Copy link
Contributor

Choose a reason for hiding this comment

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

k looks fine, what about higher freq than microsecond? these are ok in the get_date_info path?

Copy link
Member Author

Choose a reason for hiding this comment

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

what about higher freq than microsecond? these are ok in the get_date_info path?

I've got another branch im working on to handle that; it'll end up de-duplicating some code in the process

Copy link
Contributor

Choose a reason for hiding this comment

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

kk

@jreback jreback added this to the 1.1 milestone Feb 2, 2020
@jreback
Copy link
Contributor

jreback commented Feb 2, 2020

ping on green

@jbrockmendel
Copy link
Member Author

updated with a fix to missing import, which I expect will be causing most CI runs to fail until it gets patched

@jbrockmendel
Copy link
Member Author

ping

@jbrockmendel
Copy link
Member Author

gentle ping @WillAyd; this is a blocker

@jreback jreback merged commit 4fa44b7 into pandas-dev:master Feb 4, 2020
@jbrockmendel jbrockmendel deleted the bug-period branch February 4, 2020 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Period Period data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants