Skip to content

Commit

Permalink
BUG: inferred_freq with non-nano (pandas-dev#55609)
Browse files Browse the repository at this point in the history
* BUG: inferred_freq with non-nano

* GH ref
  • Loading branch information
jbrockmendel authored Oct 22, 2023
1 parent 54a65e0 commit fdcdd4c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
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

0 comments on commit fdcdd4c

Please sign in to comment.