From de055f44a2e57045cd45297fa05f1ae92a696a4b Mon Sep 17 00:00:00 2001 From: Edward Oyieko Date: Wed, 14 Feb 2024 16:28:19 +0300 Subject: [PATCH 1/2] Updated core.py, test_dataframe.py - items method --- dask/dataframe/core.py | 4 ++++ dask/dataframe/tests/test_dataframe.py | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/dask/dataframe/core.py b/dask/dataframe/core.py index e5b5a40bb41..75cd7a4bc51 100644 --- a/dask/dataframe/core.py +++ b/dask/dataframe/core.py @@ -4338,6 +4338,10 @@ def groupby( **kwargs, ) + @derived_from(pd.Series) + def items(self): + return zip(self.index, self) + @derived_from(pd.Series) def count(self, split_every=False): return super().count(split_every=split_every) diff --git a/dask/dataframe/tests/test_dataframe.py b/dask/dataframe/tests/test_dataframe.py index 06e3abdcfb8..5d170b2394f 100644 --- a/dask/dataframe/tests/test_dataframe.py +++ b/dask/dataframe/tests/test_dataframe.py @@ -1433,6 +1433,15 @@ def test_unique(): assert ddf.x.unique(split_every=2)._name != ddf.x.unique()._name +def test_items(): + s1 = pd.Series([1, 2, 3, 4], index=['a', 'b', 'c', 'd']) + dask_s1 = dd.from_pandas(s1, npartitions=1) + + for (k1, v1), (k2, v2) in zip(dask_s1.items(), s1.items()): + assert k1 == k2 + assert_eq(v1, v2) + + def test_isin(): f_list = [1, 2, 3] f_series = pd.Series(f_list) From 557b69182ea06b4cabbb2fae7854f42ce9509f36 Mon Sep 17 00:00:00 2001 From: Edward Oyieko Date: Wed, 14 Feb 2024 16:46:51 +0300 Subject: [PATCH 2/2] Updated test_dataframe.py - Linting --- dask/dataframe/tests/test_dataframe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dask/dataframe/tests/test_dataframe.py b/dask/dataframe/tests/test_dataframe.py index 5d170b2394f..b83c6dd5d8e 100644 --- a/dask/dataframe/tests/test_dataframe.py +++ b/dask/dataframe/tests/test_dataframe.py @@ -1434,7 +1434,7 @@ def test_unique(): def test_items(): - s1 = pd.Series([1, 2, 3, 4], index=['a', 'b', 'c', 'd']) + s1 = pd.Series([1, 2, 3, 4], index=["a", "b", "c", "d"]) dask_s1 = dd.from_pandas(s1, npartitions=1) for (k1, v1), (k2, v2) in zip(dask_s1.items(), s1.items()):