From b8096b7a772eb45ca3334f9e05572b2c43a50185 Mon Sep 17 00:00:00 2001 From: rmihael Date: Tue, 19 Dec 2017 18:22:46 +0200 Subject: [PATCH] Make DatetimeIndex iterator pickleable by dill Currently, dill (https://github.com/uqfoundation/dill) cannot pickle iterators over DatetimeIndex because they are generators. This simple change removes that limitation. --- pandas/core/indexes/datetimes.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index ec5c20d341b50..bec26ef72d63a 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -1251,8 +1251,7 @@ def __iter__(self): converted = libts.ints_to_pydatetime(data[start_i:end_i], tz=self.tz, freq=self.freq, box="timestamp") - for v in converted: - yield v + return iter(converted) def _wrap_union_result(self, other, result): name = self.name if self.name == other.name else None