-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
ENH: read_stata return non-nano #55642
Conversation
Does the writer code automatically handle non-ns timestamps? Or does it need some work? I give some time if needed. |
IIUC _datetime_to_stata_elapsed_vec handles this correctly, but another pair of eyeballs would be a good idea |
if fmt.startswith(("%tc", "tc")): | ||
# Delta ms relative to base | ||
td = np.timedelta64(stata_epoch - unix_epoch, "ms") | ||
res = np.array(dates._values, dtype="M8[ms]") + td |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not very familiar with this part of the code base, but this looks like it would overflow when dates._values
are close to the minimum storage value. Does numpy catch that for us or return junk values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch. numpy does not catch this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bashtage am i right in thinking stata doesn't support dates millions of years in the past/future so we don't need to worry about these overflows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just did a check of type tc
and found that the maximum date it would represent is 31Dec9999 21:41:39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This value is stored as 253717911699456
@bashtage gentle ping |
Will take a look later today. |
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
ce09bf0
to
7b802c7
Compare
Thanks @jbrockmendel |
* ENH: read_stata return non-nano * GH ref * mypy fixup * update doctest * simplify * avoid Series.view * dont go through Series * move whatsnew * remove outdated whatsnew
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Pre-emptively addresses issues that come up when implementing #55564
cc @bashtage