Skip to content

CLN: non-nano follow-ups #47682

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

Merged
merged 1 commit into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/_libs/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def format_array_from_datetime(
# a format based on precision
basic_format = format is None
if basic_format:
reso_obj = get_resolution(values, reso=reso)
reso_obj = get_resolution(values, tz=tz, reso=reso)
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't affect any tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

correct; tz is None here, just making it explicitly passed

show_ns = reso_obj == Resolution.RESO_NS
show_us = reso_obj == Resolution.RESO_US
show_ms = reso_obj == Resolution.RESO_MS
Expand Down
4 changes: 4 additions & 0 deletions pandas/_libs/tslibs/conversion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,13 @@ cpdef inline (int64_t, int) precision_from_unit(str unit):
NPY_DATETIMEUNIT reso = abbrev_to_npy_unit(unit)

if reso == NPY_DATETIMEUNIT.NPY_FR_Y:
# each 400 years we have 97 leap years, for an average of 97/400=.2425
# extra days each year. We get 31556952 by writing
# 3600*24*365.2425=31556952
m = 1_000_000_000 * 31556952
p = 9
elif reso == NPY_DATETIMEUNIT.NPY_FR_M:
# 2629746 comes from dividing the "Y" case by 12.
m = 1_000_000_000 * 2629746
p = 9
elif reso == NPY_DATETIMEUNIT.NPY_FR_W:
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/vectorized.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ def ints_to_pydatetime(
def tz_convert_from_utc(
stamps: npt.NDArray[np.int64],
tz: tzinfo | None,
reso: int = ...,
reso: int = ..., # NPY_DATETIMEUNIT
) -> npt.NDArray[np.int64]: ...
1 change: 1 addition & 0 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6897,6 +6897,7 @@ def insert(self, loc: int, item) -> Index:

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

def drop(
Expand Down