10000 BUG #34621 added nanosecond support to class Period by OlivierLuG · Pull Request #34720 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

BUG #34621 added nanosecond support to class Period #34720

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

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
10000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
#34621 Added nanosecond support to Period constructor
  • Loading branch information
OlivierLuG committed Jun 16, 2020
commit 8a559cb07f2c731b0ab83fe08ccc20c59b5157b9
6 changes: 3 additions & 3 deletions pandas/_libs/tslibs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ from pandas._libs.tslibs.np_datetime cimport (
NPY_FR_D,
NPY_FR_us,
)
from pandas._libs.tslibs.np_datetime import OutOfBoundsDatetime

cdef extern from "src/datetime/np_datetime.h":
int64_t npy_datetimestruct_to_datetime(NPY_DATETIMEUNIT fr,
Expand Down Expand Up @@ -2408,11 +2407,12 @@ class Period(_Period):
dt, reso = parse_time_string(value, freq)
try:
ts = Timestamp(value)
except ValueError:
Copy link
Contributor

Choose a reason for hiding this comment

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

we end up parsing this twice which is not good, yeah i think this needs to be integrated a bit more to parse_time_string.

i guess the currently soln would be ok in the interim, but would need to run asv's on all periods to see what kind of perf hit here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far I read, nanosecond was not accepted into dateutil module. This interim solution could stand for a while.
I stay tuned...

Copy link
Contributor

Choose a reason for hiding this comment

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

As far I read, nanosecond was not accepted into dateutil module. This interim solution could stand for a while.
I stay tuned...

we don't wait for dateutil in this, as it will not likey every support nanosecond because the standard library does not

nanosecond = 0
else:
nanosecond = ts.nanosecond
if nanosecond != 0:
reso = 'nanosecond'
except ValueError:
nanosecond = 0
if dt is NaT:
ordinal = NPY_NAT

Expand Down
0