Skip to content

Commit e1d82cb

Browse files
committed
remove is_period and fix some tests [skip ci]
1 parent 184debf commit e1d82cb

19 files changed

+156
-156
lines changed

Diff for: pandas/_libs/tslibs/period.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2372,7 +2372,7 @@ cdef class _Period(PeriodMixin):
23722372
"""
23732373
Return a string representation of the frequency.
23742374
"""
2375-
return self.freq.freqstr.replace("ME", "M")
2375+
return self.freq.freqstr
23762376

23772377
def __repr__(self) -> str:
23782378
base = self._dtype._dtype_code

Diff for: pandas/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ def rand_series_with_duplicate_datetimeindex() -> Series:
919919
params=[
920920
(Interval(left=0, right=5), IntervalDtype("int64", "right")),
921921
(Interval(left=0.1, right=0.5), IntervalDtype("float64", "right")),
922-
(Period("2012-01", freq="M"), "period[M]"),
922+
(Period("2012-01", freq="ME"), "period[ME]"),
923923
(Period("2012-02-01", freq="D"), "period[D]"),
924924
(
925925
Timestamp("2011-01-01", tz="US/Eastern"),

Diff for: pandas/tests/apply/test_frame_apply.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,8 @@ def test_applymap_box():
653653
],
654654
"c": [pd.Timedelta("1 days"), pd.Timedelta("2 days")],
655655
"d": [
656-
pd.Period("2011-01-01", freq="M"),
657-
pd.Period("2011-01-02", freq="M"),
656+
pd.Period("2011-01-01", freq="ME"),
657+
pd.Period("2011-01-02", freq="ME"),
658658
],
659659
}
660660
)

Diff for: pandas/tests/apply/test_series_apply.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ def test_apply_box():
182182
tm.assert_series_equal(res, exp)
183183

184184
# period
185-
vals = [pd.Period("2011-01-01", freq="M"), pd.Period("2011-01-02", freq="M")]
185+
vals = [pd.Period("2011-01-01", freq="ME"), pd.Period("2011-01-02", freq="ME")]
186186
s = Series(vals)
187-
assert s.dtype == "Period[M]"
187+
assert s.dtype == "Period[ME]"
188188
res = s.apply(lambda x: f"{type(x).__name__}_{x.freqstr}")
189-
exp = Series(["Period_M", "Period_M"])
189+
exp = Series(["Period_ME", "Period_ME"])
190190
tm.assert_series_equal(res, exp)
191191

192192

@@ -740,11 +740,11 @@ def test_map_box():
740740
tm.assert_series_equal(res, exp)
741741

742742
# period
743-
vals = [pd.Period("2011-01-01", freq="M"), pd.Period("2011-01-02", freq="M")]
743+
vals = [pd.Period("2011-01-01", freq="ME"), pd.Period("2011-01-02", freq="ME")]
744744
s = Series(vals)
745-
assert s.dtype == "Period[M]"
745+
assert s.dtype == "Period[ME]"
746746
res = s.apply(lambda x: f"{type(x).__name__}_{x.freqstr}")
747-
exp = Series(["Period_M", "Period_M"])
747+
exp = Series(["Period_ME", "Period_ME"])
748748
tm.assert_series_equal(res, exp)
749749

750750

Diff for: pandas/tests/arithmetic/test_datetime64.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ class TestDatetime64SeriesComparison:
173173
[NaT, NaT, Timedelta("3 days")],
174174
),
175175
(
176-
[Period("2011-01", freq="M"), NaT, Period("2011-03", freq="M")],
177-
[NaT, NaT, Period("2011-03", freq="M")],
176+
[Period("2011-01", freq="ME"), NaT, Period("2011-03", freq="ME")],
177+
[NaT, NaT, Period("2011-03", freq="ME")],
178178
),
179179
],
180180
)
@@ -218,7 +218,7 @@ def test_nat_comparisons(
218218
[
219219
[Timestamp("2011-01-01"), NaT, Timestamp("2011-01-03")],
220220
[Timedelta("1 days"), NaT, Timedelta("3 days")],
221-
[Period("2011-01", freq="M"), NaT, Period("2011-03", freq="M")],
221+
[Period("2011-01", freq="ME"), NaT, Period("2011-03", freq="ME")],
222222
],
223223
)
224224
@pytest.mark.parametrize("dtype", [None, object])
@@ -1078,7 +1078,7 @@ def test_dt64arr_add_dtlike_raises(self, tz_naive_fixture, box_with_array):
10781078
# Note: freq here includes both Tick and non-Tick offsets; this is
10791079
# relevant because historically integer-addition was allowed if we had
10801080
# a freq.
1081-
@pytest.mark.parametrize("freq", ["H", "D", "W", "M", "MS", "Q", "B", None])
1081+
@pytest.mark.parametrize("freq", ["H", "D", "W", "ME", "MS", "Q", "B", None])
10821082
@pytest.mark.parametrize("dtype", [None, "uint8"])
10831083
def test_dt64arr_addsub_intlike(
10841084
self, dtype, box_with_array, freq, tz_naive_fixture

0 commit comments

Comments
 (0)