Skip to content

Commit 0e57257

Browse files
jbrockmendelyehoshuadimarsky
authored andcommitted
CLN: non-nano follow-ups (pandas-dev#47682)
1 parent a4e3fe0 commit 0e57257

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

pandas/_libs/tslib.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def format_array_from_datetime(
152152
# a format based on precision
153153
basic_format = format is None
154154
if basic_format:
155-
reso_obj = get_resolution(values, reso=reso)
155+
reso_obj = get_resolution(values, tz=tz, reso=reso)
156156
show_ns = reso_obj == Resolution.RESO_NS
157157
show_us = reso_obj == Resolution.RESO_US
158158
show_ms = reso_obj == Resolution.RESO_MS

pandas/_libs/tslibs/conversion.pyx

+4
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,13 @@ cpdef inline (int64_t, int) precision_from_unit(str unit):
144144
NPY_DATETIMEUNIT reso = abbrev_to_npy_unit(unit)
145145

146146
if reso == NPY_DATETIMEUNIT.NPY_FR_Y:
147+
# each 400 years we have 97 leap years, for an average of 97/400=.2425
148+
# extra days each year. We get 31556952 by writing
149+
# 3600*24*365.2425=31556952
147150
m = 1_000_000_000 * 31556952
148151
p = 9
149152
elif reso == NPY_DATETIMEUNIT.NPY_FR_M:
153+
# 2629746 comes from dividing the "Y" case by 12.
150154
m = 1_000_000_000 * 2629746
151155
p = 9
152156
elif reso == NPY_DATETIMEUNIT.NPY_FR_W:

pandas/_libs/tslibs/vectorized.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ def ints_to_pydatetime(
4242
def tz_convert_from_utc(
4343
stamps: npt.NDArray[np.int64],
4444
tz: tzinfo | None,
45-
reso: int = ...,
45+
reso: int = ..., # NPY_DATETIMEUNIT
4646
) -> npt.NDArray[np.int64]: ...

pandas/core/indexes/base.py

+1
Original file line numberDiff line numberDiff line change
@@ -6897,6 +6897,7 @@ def insert(self, loc: int, item) -> Index:
68976897

68986898
# Use self._constructor instead of Index to retain NumericIndex GH#43921
68996899
# TODO(2.0) can use Index instead of self._constructor
6900+
# Check if doing so fixes GH#47071
69006901
return self._constructor._with_infer(new_values, name=self.name)
69016902

69026903
def drop(

0 commit comments

Comments
 (0)