Skip to content

Commit 772b13a

Browse files
author
Tom Augspurger
committed
Merge pull request #6761 from TomAugspurger/lazy-iteritems
BUG: Series.iteritems should be lazy
2 parents 95a562c + 373ab0f commit 772b13a

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

doc/source/release.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ API Changes
151151
- ``DataFrame.sort`` now places NaNs at the beginning or end of the sort according to the ``na_position`` parameter. (:issue:`3917`)
152152

153153
- all offset operations now return ``Timestamp`` types (rather than datetime), Business/Week frequencies were incorrect (:issue:`4069`)
154-
154+
- ``Series.iteritems()`` is now lazy (returns an iterator rather than a list). This was the documented behavior prior to 0.14. (:issue:`6760`)
155155

156156
Deprecations
157157
~~~~~~~~~~~~

doc/source/v0.14.0.txt

+2
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ API changes
196196
covs = rolling_cov(df[['A','B','C']], df[['B','C','D']], 5, pairwise=True)
197197
covs[df.index[-1]]
198198

199+
- ``Series.iteritems()`` is now lazy (returns an iterator rather than a list). This was the documented behavior prior to 0.14. (:issue:`6760`)
200+
199201

200202
MultiIndexing Using Slicers
201203
~~~~~~~~~~~~~~~~~~~~~~~~~~~

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ def iteritems(self):
959959
"""
960960
Lazily iterate over (index, value) tuples
961961
"""
962-
return lzip(iter(self.index), iter(self))
962+
return zip(iter(self.index), iter(self))
963963

964964
if compat.PY3: # pragma: no cover
965965
items = iteritems

pandas/tests/test_series.py

+3
Original file line numberDiff line numberDiff line change
@@ -1808,6 +1808,9 @@ def test_iteritems(self):
18081808
for idx, val in compat.iteritems(self.ts):
18091809
self.assertEqual(val, self.ts[idx])
18101810

1811+
# assert is lazy (genrators don't define __getslice__, lists do)
1812+
self.assertFalse(hasattr(self.series.iteritems(), '__getslice__'))
1813+
18111814
def test_sum(self):
18121815
self._check_stat_op('sum', np.sum)
18131816

0 commit comments

Comments
 (0)