Skip to content

Commit 98f2c91

Browse files
committed
BUG: Fix hour for Period with ordinal >= 2562048
1 parent 8f6ec1e commit 98f2c91

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pandas/_libs/tslibs/period.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ cdef int64_t get_time_nanos(int freq, int64_t unix_date, int64_t ordinal) nogil:
861861
"""
862862
cdef:
863863
int64_t sub, factor
864+
int64_t nanos_in_day = 24 * 3600 * 10**9
864865

865866
freq = get_freq_group(freq)
866867

@@ -886,7 +887,7 @@ cdef int64_t get_time_nanos(int freq, int64_t unix_date, int64_t ordinal) nogil:
886887
# We must have freq == FR_HR
887888
factor = 10**9 * 3600
888889

889-
sub = ordinal - unix_date * 24 * 3600 * 10**9 / factor
890+
sub = ordinal - unix_date * (nanos_in_day / factor)
890891
return sub * factor
891892

892893

0 commit comments

Comments
 (0)