From 761ac0e839f34606e5e4f0b08f450cbb3a48504b Mon Sep 17 00:00:00 2001 From: Aniket Singh Yadav Date: Mon, 25 Aug 2025 04:26:39 +0530 Subject: [PATCH 1/6] DOC: Clarify list-like vs scalar in Series.eq docstring --- pandas/core/series.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index b40e71f2b5b42..52a045c2d0f37 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -6072,7 +6072,9 @@ def eq( Parameters ---------- other : Series or scalar value - The second operand in this operation. + The second operand in this operation. Only `np.ndarray`, `list`, `tuple`, + and `Series` are considered "list-like" by pandas. All other types will + be treated as scalar values. level : int or name Broadcast across a level, matching Index values on the passed MultiIndex level. From a85ab96a599ddbbfdbd76d3b9193be57590fe5b7 Mon Sep 17 00:00:00 2001 From: Aniket Singh Yadav Date: Mon, 8 Sep 2025 12:14:39 +0530 Subject: [PATCH 2/6] Add unit tests for tm.shares_memory (#55372) --- pandas/tests/util/test_shares_memory.py | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/pandas/tests/util/test_shares_memory.py b/pandas/tests/util/test_shares_memory.py index 8f1ac93b40247..570b88dc653bc 100644 --- a/pandas/tests/util/test_shares_memory.py +++ b/pandas/tests/util/test_shares_memory.py @@ -30,3 +30,42 @@ def test_shares_memory_string(): obj = pd.array(["a", "b"], dtype=pd.ArrowDtype(pa.string())) assert tm.shares_memory(obj, obj) + + +# Unit tests for tm.shares_memory (#55372) +def test_shares_memory_numpy(): + arr = np.arange(10) + view = arr[:5] + assert tm.shares_memory(arr, view) + arr2 = np.arange(10) + assert not tm.shares_memory(arr, arr2) + + +def test_shares_memory_series(): + arr = np.arange(10) + s = pd.Series(arr) + assert tm.shares_memory(arr, s) + s2 = pd.Series(np.arange(10)) + assert not tm.shares_memory(s, s2) + + +def test_shares_memory_dataframe_single_block(): + arr = np.arange(10) + df = pd.DataFrame({"a": arr}) + assert tm.shares_memory(arr, df) + df2 = pd.DataFrame({"a": np.arange(10)}) + assert not tm.shares_memory(df, df2) + + +def test_shares_memory_rangeindex(): + idx = pd.RangeIndex(10) + arr = np.arange(10) + assert not tm.shares_memory(idx, arr) + + +def test_shares_memory_multiindex(): + idx = pd.MultiIndex.from_arrays([np.arange(10), np.arange(10, 20)]) + arr = idx.codes[0] + assert tm.shares_memory(idx, arr) + arr2 = np.arange(10) + assert not tm.shares_memory(idx, arr2) From a0769ff0f7a8b3019b4958461265472e006210cb Mon Sep 17 00:00:00 2001 From: Aniket Singh Yadav Date: Mon, 8 Sep 2025 12:21:02 +0530 Subject: [PATCH 3/6] Remove unrelated changes to pandas/core/series.py --- pandas/core/series.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 9243e7653eccd..7190461adf431 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -6071,9 +6071,7 @@ def eq( Parameters ---------- other : Series or scalar value - The second operand in this operation. Only `np.ndarray`, `list`, `tuple`, - and `Series` are considered "list-like" by pandas. All other types will - be treated as scalar values. + The second operand in this operation. level : int or name Broadcast across a level, matching Index values on the passed MultiIndex level. From ff3472bebc66eeba57c93a7e920e9b291dd21952 Mon Sep 17 00:00:00 2001 From: Aniket Singh Yadav Date: Mon, 8 Sep 2025 13:18:37 +0530 Subject: [PATCH 4/6] Add unit tests for tm.shares_memory (#55372) --- pandas/tests/util/test_shares_memory.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pandas/tests/util/test_shares_memory.py b/pandas/tests/util/test_shares_memory.py index 570b88dc653bc..f1f9da1a43bc7 100644 --- a/pandas/tests/util/test_shares_memory.py +++ b/pandas/tests/util/test_shares_memory.py @@ -44,7 +44,7 @@ def test_shares_memory_numpy(): def test_shares_memory_series(): arr = np.arange(10) s = pd.Series(arr) - assert tm.shares_memory(arr, s) + assert tm.shares_memory(s, arr) s2 = pd.Series(np.arange(10)) assert not tm.shares_memory(s, s2) @@ -52,7 +52,7 @@ def test_shares_memory_series(): def test_shares_memory_dataframe_single_block(): arr = np.arange(10) df = pd.DataFrame({"a": arr}) - assert tm.shares_memory(arr, df) + assert tm.shares_memory(df, arr) df2 = pd.DataFrame({"a": np.arange(10)}) assert not tm.shares_memory(df, df2) @@ -65,7 +65,5 @@ def test_shares_memory_rangeindex(): def test_shares_memory_multiindex(): idx = pd.MultiIndex.from_arrays([np.arange(10), np.arange(10, 20)]) - arr = idx.codes[0] - assert tm.shares_memory(idx, arr) arr2 = np.arange(10) assert not tm.shares_memory(idx, arr2) From 64a2fe31a4627110ca8315f0dee100ca5099ac98 Mon Sep 17 00:00:00 2001 From: Aniket Singh Yadav Date: Mon, 8 Sep 2025 13:46:02 +0530 Subject: [PATCH 5/6] Add unit tests for tm.shares_memory (#55372) --- pandas/tests/util/test_shares_memory.py | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/pandas/tests/util/test_shares_memory.py b/pandas/tests/util/test_shares_memory.py index f1f9da1a43bc7..a3447d525f8c8 100644 --- a/pandas/tests/util/test_shares_memory.py +++ b/pandas/tests/util/test_shares_memory.py @@ -41,29 +41,7 @@ def test_shares_memory_numpy(): assert not tm.shares_memory(arr, arr2) -def test_shares_memory_series(): - arr = np.arange(10) - s = pd.Series(arr) - assert tm.shares_memory(s, arr) - s2 = pd.Series(np.arange(10)) - assert not tm.shares_memory(s, s2) - - -def test_shares_memory_dataframe_single_block(): - arr = np.arange(10) - df = pd.DataFrame({"a": arr}) - assert tm.shares_memory(df, arr) - df2 = pd.DataFrame({"a": np.arange(10)}) - assert not tm.shares_memory(df, df2) - - def test_shares_memory_rangeindex(): idx = pd.RangeIndex(10) arr = np.arange(10) assert not tm.shares_memory(idx, arr) - - -def test_shares_memory_multiindex(): - idx = pd.MultiIndex.from_arrays([np.arange(10), np.arange(10, 20)]) - arr2 = np.arange(10) - assert not tm.shares_memory(idx, arr2) From 92497fb2de6b433dbd03d4c9e1b0408693bf5a05 Mon Sep 17 00:00:00 2001 From: Aniket Singh Yadav Date: Tue, 9 Sep 2025 00:15:24 +0530 Subject: [PATCH 6/6] Add unit tests for tm.shares_memory (#55372) --- pandas/tests/util/test_shares_memory.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/tests/util/test_shares_memory.py b/pandas/tests/util/test_shares_memory.py index a3447d525f8c8..94bc51dca3f60 100644 --- a/pandas/tests/util/test_shares_memory.py +++ b/pandas/tests/util/test_shares_memory.py @@ -32,7 +32,6 @@ def test_shares_memory_string(): assert tm.shares_memory(obj, obj) -# Unit tests for tm.shares_memory (#55372) def test_shares_memory_numpy(): arr = np.arange(10) view = arr[:5]