# Buggy code
def _new_DatetimeIndex(cls, d):
    """This is called upon unpickling, rather than the default which doesn't have arguments
    and breaks __new__"""

    # data are already in UTC
    # so need to localize
    tz = d.pop("tz", None)
    result = cls.__new__(cls, **d)
    if tz is not None:
        result = result.tz_localize("UTC").tz_convert(tz)
    return result


# Traceback (ValueError)
import pandas as pd
df4 = pd.DataFrame(index=P.date_range('1750-1-1', '2050-1-1', freq='7D')
pd.to_pickle(df4, '7d.test')
pd.read_pickle('7d.test')


In [84]: P.read_pickle('7d.test')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-84-0108eecfbea7> in <module>()
----> 1 P.read_pickle('7d.test')

C:\Users\LV\Miniconda\lib\site-packages\pandas\io\pickle.pyc in read_pickle(path)
58
59     try:
---> 60         return try_read(path)
61     except:
62         if PY3:

C:\Users\LV\Miniconda\lib\site-packages\pandas\io\pickle.pyc in try_read(path, encoding)
55             except:
56                 with open(path, 'rb') as fh:
---> 57                     return pc.load(fh, encoding=encoding, compat=True)
58
59     try:

C:\Users\LV\Miniconda\lib\site-packages\pandas\compat\pickle_compat.pyc in load(fh, encoding, compat, is_verbose)
114         up.is_verbose = is_verbose
115
--> 116         return up.load()
117     except:
118         raise

C:\Users\LV\Miniconda\lib\pickle.pyc in load(self)
856             while 1:
857                 key = read(1)
--> 858                 dispatch[key](self)
859         except _Stop, stopinst:
860             return stopinst.value

C:\Users\LV\Miniconda\lib\site-packages\pandas\compat\pickle_compat.pyc in load_reduce(self)
18
19     try:
---> 20         stack[-1] = func(*args)
21         return
22     except Exception as e:

C:\Users\LV\Miniconda\lib\site-packages\pandas\tseries\index.pyc in _new_DatetimeIndex(cls, d)
113     # data are already in UTC
114     tz = d.pop('tz',None)
--> 115     result = cls.__new__(cls, **d)
116     result.tz = tz
117     return result

C:\Users\LV\Miniconda\lib\site-packages\pandas\util\decorators.pyc in wrapper(*args, **kwargs)
86                 else:
87                     kwargs[new_arg_name] = new_arg_value
---> 88             return func(*args, **kwargs)
89         return wrapper
90     return _deprecate_kwarg

C:\Users\LV\Miniconda\lib\site-packages\pandas\tseries\index.pyc in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, closed, ambiguous, **kwargs)
334                     if not np.array_equal(subarr.asi8, on_freq.asi8):
335                         raise ValueError('Inferred frequency {0} from passed dates does not'
--> 336                                          'conform to passed frequency {1}'.format(inferred, freq.freqstr))
337
338         if freq_infer:

ValueError: Inferred frequency W-THU from passed dates does notconform to passed frequency 7D

# Fixed code
def _new_DatetimeIndex(cls, d):
    """This is called upon unpickling, rather than the default which doesn't have arguments
    and breaks __new__"""

    # data are already in UTC
    # so need to localize
    tz = d.pop("tz", None)

    result = cls.__new__(cls, verify_integrity=False, **d)
    if tz is not None:
        result = result.tz_localize("UTC").tz_convert(tz)
    return result