Skip to content

Commit ff3473c

Browse files
committed
BUG: Bug in pickling of a non-regular freq DatetimeIndex #11002
1 parent f5b85ca commit ff3473c

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

doc/source/whatsnew/v0.17.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ Bug Fixes
894894
- Bug in clearing the cache on ``DataFrame.pop`` and a subsequent inplace op (:issue:`10912`)
895895
- Bug in indexing with a mixed-integer ``Index`` causing an ``ImportError`` (:issue:`10610`)
896896
- Bug in ``Series.count`` when index has nulls (:issue:`10946`)
897-
897+
- Bug in pickling of a non-regular freq ``DatetimeIndex`` (:issue:`11002`)
898898
- Bug causing ``DataFrame.where`` to not respect the ``axis`` parameter when the frame has a symmetric shape. (:issue:`9736`)
899899

900900
- Bug in ``Table.select_column`` where name is not preserved (:issue:`10392`)

pandas/tseries/index.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ def _new_DatetimeIndex(cls, d):
120120
# data are already in UTC
121121
# so need to localize
122122
tz = d.pop('tz',None)
123-
result = cls.__new__(cls, **d)
123+
124+
result = cls.__new__(cls, verify_integrity=False, **d)
124125
if tz is not None:
125126
result = result.tz_localize('UTC').tz_convert(tz)
126127
return result

pandas/tseries/tests/test_timeseries.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -2142,8 +2142,8 @@ def test_period_resample_with_local_timezone_dateutil(self):
21422142

21432143

21442144
def test_pickle(self):
2145-
#GH4606
21462145

2146+
# GH4606
21472147
p = self.round_trip_pickle(NaT)
21482148
self.assertTrue(p is NaT)
21492149

@@ -2153,6 +2153,11 @@ def test_pickle(self):
21532153
self.assertTrue(idx_p[1] is NaT)
21542154
self.assertTrue(idx_p[2] == idx[2])
21552155

2156+
# GH11002
2157+
# don't infer freq
2158+
idx = date_range('1750-1-1', '2050-1-1', freq='7D')
2159+
idx_p = self.round_trip_pickle(idx)
2160+
tm.assert_index_equal(idx, idx_p)
21562161

21572162
def _simple_ts(start, end, freq='D'):
21582163
rng = date_range(start, end, freq=freq)

0 commit comments

Comments
 (0)