nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: pandas-dev/pandas
Pull request #56489 (2023-12-13 18:59:23)

DEPR: raise ValueError if invalid period freq pass to asfreq
xref #52064, #9586

in example:
```
index = pd.PeriodIndex(["2020-01-01", "2021-01-01"], freq="M")
df = pd.DataFrame({"a": pd.Series([0, 1], index=index)})
df.asfreq(freq=MonthBegin(2))
```
we silently convert " 2MS" to " 2M", which isn't correct.

Raised` ValueError` if invalid period freq pass to `asfreq()`



Patch:
diff --git a/pandas/core/resample.py b/pandas/core/resample.py
index b3e86b4360..39b2f43367 100644
--- a/pandas/core/resample.py
+++ b/pandas/core/resample.py
@@ -2784,7 +2784,13 @@ def asfreq(
             how = "E"
 
         if isinstance(freq, BaseOffset):
-            freq = freq_to_period_freqstr(freq.n, freq.name)
+            if hasattr(freq, "_period_dtype_code"):
+                freq = freq_to_period_freqstr(freq.n, freq.name)
+            else:
+                raise ValueError(
+                    f"Invalid offset: '{freq.base}' for converting time series "
+                    f"with PeriodIndex."
+                )
 
         new_obj = obj.copy()
         new_obj.index = obj.index.asfreq(freq, how=how)


Test patch:
diff --git a/pandas/tests/resample/test_period_index.py b/pandas/tests/resample/test_period_index.py
index 60b222179b..703abbca91 100644
--- a/pandas/tests/resample/test_period_index.py
+++ b/pandas/tests/resample/test_period_index.py
@@ -970,6 +970,22 @@ class TestPeriodIndex:
             result = ser.resample("T").mean()
         tm.assert_series_equal(result, expected)
 
+    @pytest.mark.parametrize(
+        "offset",
+        [
+            offsets.MonthBegin(),
+            offsets.BYearBegin(2),
+            offsets.BusinessHour(2),
+        ],
+    )
+    def test_asfreq_invalid_period_freq(self, offset, series_and_frame):
+        # GH#9586
+        msg = f"Invalid offset: '{offset.base}' for converting time series "
+
+        df = series_and_frame
+        with pytest.raises(ValueError, match=msg):
+            df.asfreq(freq=offset)
+
 
 @pytest.mark.parametrize(
     "freq,freq_depr",
Repository: pandas-dev/pandas
Pull request #56584 (2023-12-20 23:51:40)

CI: Disable linkecheck
Since this job is not fully ready yet, going to disable as it can "fail" if the right files were modified


Patch:
diff --git a/.github/workflows/broken-linkcheck.yml b/.github/workflows/broken-linkcheck.yml
index 10ab5b08a4..191252cccf 100644
--- a/.github/workflows/broken-linkcheck.yml
+++ b/.github/workflows/broken-linkcheck.yml
@@ -9,6 +9,7 @@ on:
       - "doc/make.py"
 jobs:
   linkcheck:
+    if: false
     runs-on: ubuntu-latest
     defaults:
       run:
diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py
index 1af2d9e739..20eff9315b 100644
--- a/pandas/core/internals/blocks.py
+++ b/pandas/core/internals/blocks.py
@@ -746,7 +746,7 @@ class Block(PandasObject, libinternals.Block):
         Block
         """
         values = self.values
-        if squeeze and values.ndim == 2:
+        if squeeze and values.ndim == 2 and is_1d_only_ea_dtype(dtype):
             if values.shape[0] != 1:
                 raise ValueError("Can not squeeze with more than one column.")
             values = values[0, :]  # type: ignore[call-overload]


Test patch:
diff --git a/pandas/tests/frame/methods/test_convert_dtypes.py b/pandas/tests/frame/methods/test_convert_dtypes.py
index a181a27118..521d2cb14a 100644
--- a/pandas/tests/frame/methods/test_convert_dtypes.py
+++ b/pandas/tests/frame/methods/test_convert_dtypes.py
@@ -193,3 +193,10 @@ class TestConvertDtypes:
         )
         tm.assert_frame_equal(result, expected)
         assert result._mgr.nblocks == 2
+
+    def test_convert_dtypes_from_arrow(self):
+        # GH#56581
+        df = pd.DataFrame([["a", datetime.time(18, 12)]], columns=["a", "b"])
+        result = df.convert_dtypes()
+        expected = df.astype({"a": "string[python]"})
+        tm.assert_frame_equal(result, expected)
Repository: pandas-dev/pandas
Pull request #56831 (2024-01-11 11:07:10)

BUG fix for date_range 56134
- [X] closes https://github.com/pandas-dev/pandas/issues/56134
- [X] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [X] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [X] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions.
- [X] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.

Edit, the first commit is incorrectly named - it fixes 56134 instead


jrmylow: pre-commit.ci autofix
MarcoGorelli: Thanks for updating!

> Edit, the first commit is incorrectly named - it fixes 56134 instead

it's fine, commits are squashed together anyway, the title of the PR is more important

Patch:
diff --git a/doc/source/whatsnew/v2.3.0.rst b/doc/source/whatsnew/v2.3.0.rst
index 7b53ddb392..75f68e1bd0 100644
--- a/doc/source/whatsnew/v2.3.0.rst
+++ b/doc/source/whatsnew/v2.3.0.rst
@@ -119,7 +119,7 @@ Categorical
 
 Datetimelike
 ^^^^^^^^^^^^
--
+- Bug in :func:`date_range` where the last valid timestamp would sometimes not be produced (:issue:`56134`)
 -
 
 Timedelta
diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py
index a4d01dd666..8a9b19dc79 100644
--- a/pandas/core/arrays/datetimes.py
+++ b/pandas/core/arrays/datetimes.py
@@ -2775,11 +2775,6 @@ def _generate_range(
         # variable has type "Optional[Timestamp]")
         start = offset.rollforward(start)  # type: ignore[assignment]
 
-    elif end and not offset.is_on_offset(end):
-        # Incompatible types in assignment (expression has type "datetime",
-        # variable has type "Optional[Timestamp]")
-        end = offset.rollback(end)  # type: ignore[assignment]
-
     # Unsupported operand types for < ("Timestamp" and "None")
     if periods is None and end < start and offset.n >= 0:  # type: ignore[operator]
         end = None


Test patch:
diff --git a/pandas/tests/indexes/datetimes/test_date_range.py b/pandas/tests/indexes/datetimes/test_date_range.py
index 024f37ee5b..ec158f7b19 100644
--- a/pandas/tests/indexes/datetimes/test_date_range.py
+++ b/pandas/tests/indexes/datetimes/test_date_range.py
@@ -1703,3 +1703,18 @@ class TestDateRangeNonTickFreq:
         idx2 = date_range(start=sdate, end=edate, freq=offset)
         assert len(idx1) == len(idx2)
         assert idx1.freq == idx2.freq
+
+    def test_date_range_partial_day_year_end(self, unit):
+        # GH#56134
+        rng = date_range(
+            start="2021-12-31 00:00:01",
+            end="2023-10-31 00:00:00",
+            freq="YE",
+            unit=unit,
+        )
+        exp = DatetimeIndex(
+            ["2021-12-31 00:00:01", "2022-12-31 00:00:01"],
+            dtype=f"M8[{unit}]",
+            freq="YE",
+        )
+        tm.assert_index_equal(rng, exp)
Repository: pandas-dev/pandas
Pull request #56862 (2024-01-13 20:18:33)

Backport PR #56849 on branch 2.2.x (REGR: freq "m" (as alias of deprecated "M") raises an error)
Backport PR #56849: REGR: freq "m" (as alias of deprecated "M") raises an error


Patch:
diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx
index 3a339171d0..205ab6f01f 100644
--- a/pandas/_libs/tslibs/offsets.pyx
+++ b/pandas/_libs/tslibs/offsets.pyx
@@ -4845,15 +4845,15 @@ cpdef to_offset(freq, bint is_period=False):
 
             tups = zip(split[0::4], split[1::4], split[2::4])
             for n, (sep, stride, name) in enumerate(tups):
-                if is_period is False and name in c_OFFSET_DEPR_FREQSTR:
+                if is_period is False and name.upper() in c_OFFSET_DEPR_FREQSTR:
                     warnings.warn(
                         f"\'{name}\' is deprecated and will be removed "
                         f"in a future version, please use "
-                        f"\'{c_OFFSET_DEPR_FREQSTR.get(name)}\' instead.",
+                        f"\'{c_OFFSET_DEPR_FREQSTR.get(name.upper())}\' instead.",
                         FutureWarning,
                         stacklevel=find_stack_level(),
                     )
-                    name = c_OFFSET_DEPR_FREQSTR[name]
+                    name = c_OFFSET_DEPR_FREQSTR[name.upper()]
                 if is_period is True and name in c_REVERSE_OFFSET_DEPR_FREQSTR:
                     if name.startswith("Y"):
                         raise ValueError(


Test patch:
diff --git a/pandas/tests/indexes/datetimes/test_date_range.py b/pandas/tests/indexes/datetimes/test_date_range.py
index 44dd64e162..d26bee8000 100644
--- a/pandas/tests/indexes/datetimes/test_date_range.py
+++ b/pandas/tests/indexes/datetimes/test_date_range.py
@@ -822,6 +822,17 @@ class TestDateRanges:
             result = date_range("1/1/2000", periods=2, freq=freq_depr)
         tm.assert_index_equal(result, expected)
 
+    def test_to_offset_with_lowercase_deprecated_freq(self) -> None:
+        # https://github.com/pandas-dev/pandas/issues/56847
+        msg = (
+            "'m' is deprecated and will be removed in a future version, please use "
+            "'ME' instead."
+        )
+        with tm.assert_produces_warning(FutureWarning, match=msg):
+            result = date_range("2010-01-01", periods=2, freq="m")
+        expected = DatetimeIndex(["2010-01-31", "2010-02-28"], freq="ME")
+        tm.assert_index_equal(result, expected)
+
     def test_date_range_bday(self):
         sdate = datetime(1999, 12, 25)
         idx = date_range(start=sdate, freq="1B", periods=20)
diff --git a/pandas/tests/tslibs/test_to_offset.py b/pandas/tests/tslibs/test_to_offset.py
index ef68408305..6e654e65a3 100644
--- a/pandas/tests/tslibs/test_to_offset.py
+++ b/pandas/tests/tslibs/test_to_offset.py
@@ -45,6 +45,7 @@ def test_to_offset_negative(freqstr, expected):
     assert result.n == expected
 
 
+@pytest.mark.filterwarnings("ignore:.*'m' is deprecated.*:FutureWarning")
 @pytest.mark.parametrize(
     "freqstr",
     [