Skip to content

BUG: inferred_freq with non-nano #55609

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 2 commits into from
Oct 22, 2023
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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ Styler
Other
^^^^^
- Bug in :func:`cut` incorrectly allowing cutting of timezone-aware datetimes with timezone-naive bins (:issue:`54964`)
- Bug in :func:`infer_freq` and :meth:`DatetimeIndex.inferred_freq` with weekly frequencies and non-nanosecond resolutions (:issue:`55609`)
- Bug in :meth:`DataFrame.apply` where passing ``raw=True`` ignored ``args`` passed to the applied function (:issue:`55009`)
- Bug in rendering ``inf`` values inside a a :class:`DataFrame` with the ``use_inf_as_na`` option enabled (:issue:`55483`)
- Bug in rendering a :class:`Series` with a :class:`MultiIndex` when one of the index level's names is 0 not having that name displayed (:issue:`55415`)
Expand Down
7 changes: 4 additions & 3 deletions pandas/tests/tseries/frequencies/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,11 @@ def test_infer_freq_index(freq, expected):
}.items()
),
)
def test_infer_freq_tz(tz_naive_fixture, expected, dates):
# see gh-7310
@pytest.mark.parametrize("unit", ["s", "ms", "us", "ns"])
def test_infer_freq_tz(tz_naive_fixture, expected, dates, unit):
# see gh-7310, GH#55609
tz = tz_naive_fixture
idx = DatetimeIndex(dates, tz=tz)
idx = DatetimeIndex(dates, tz=tz).as_unit(unit)
assert idx.inferred_freq == expected


Expand Down
2 changes: 1 addition & 1 deletion pandas/tseries/frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def fields(self) -> np.ndarray: # structured array of fields

@cache_readonly
def rep_stamp(self) -> Timestamp:
return Timestamp(self.i8values[0])
return Timestamp(self.i8values[0], unit=self.index.unit)

def month_position_check(self) -> str | None:
return month_position_check(self.fields, self.index.dayofweek)
Expand Down