Skip to content

Commit c768e34

Browse files
committed
BUG: Fix hour for Period with ordinal >= 2562048
1 parent 6f2c60e commit c768e34

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pandas/_libs/tslibs/period.pyx

+5-2
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ cdef int64_t get_time_nanos(int freq, int64_t unix_date, int64_t ordinal) nogil:
860860
int64_t
861861
"""
862862
cdef:
863-
int64_t sub, factor
863+
int64_t sub, factor, precompute_factor, nanos_in_day
864864

865865
freq = get_freq_group(freq)
866866

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

889-
sub = ordinal - unix_date * 24 * 3600 * 10**9 / factor
889+
# Fix issue #36430
890+
nanos_in_day = 24 * 3600 * 10**9
891+
precompute_factor = nanos_in_day / factor
892+
sub = ordinal - unix_date * precompute_factor
890893
return sub * factor
891894

892895

0 commit comments

Comments
 (0)