You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pandas.read_msgpack() throws a ValueError: Dates do not conform to passed frequency if the index is a DatetimeIndex and there are only two rows of data.
In [66]: df=pd.DataFrame([1, 2], index=pd.date_range('1/1/2013', '1/2/2013'))
In [67]: dfOut[67]:
02013-01-0112013-01-022
[2rowsx1columns]
In [68]: pd.read_msgpack(df.to_msgpack())
---------------------------------------------------------------------------ValueErrorTraceback (mostrecentcalllast)
<ipython-input-68-fae93928effe>in<module>()
---->1pd.read_msgpack(df.to_msgpack())
/home/user/environments/python3/src/pandas/pandas/io/packers.pyinread_msgpack(path_or_buf, iterator, **kwargs)
158try:
159fh=compat.BytesIO(path_or_buf)
-->160returnread(fh)
161finally:
162fh.close()
/home/user/environments/python3/src/pandas/pandas/io/packers.pyinread(fh)
136137defread(fh):
-->138l=list(unpack(fh))
139iflen(l) ==1:
140returnl[0]
/home/user/environments/python3/src/pandas/pandas/msgpack.cpython-33m.soinpandas.msgpack.Unpacker.__next__ (pandas/msgpack.cpp:7846)()
/home/user/environments/python3/src/pandas/pandas/msgpack.cpython-33m.soinpandas.msgpack.Unpacker._unpack (pandas/msgpack.cpp:6981)()
/home/user/environments/python3/src/pandas/pandas/io/packers.pyindecode(obj)
448eliftyp=='datetime_index':
449data=unconvert(obj['data'], np.int64, obj.get('compress'))
-->450result=globals()[obj['klass']](data, freq=obj['freq'], name=obj['name'])
451tz=obj['tz']
452/home/user/environments/python3/src/pandas/pandas/tseries/index.pyin__new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, closed, **kwds)
283inferred=subarr.inferred_freq284ifinferred!=offset.freqstr:
-->285raiseValueError('Dates do not conform to passed '286'frequency')
287ValueError: Datesdonotconformtopassedfrequency
Adding a third row makes the problem go away:
In [13]: df=pd.DataFrame([1, 2, 3], index=pd.date_range('1/1/2013', '1/3/2013'))
In [14]: dfOut[14]:
02013-01-0112013-01-0222013-01-033
[3rowsx1columns]
In [15]: pd.read_msgpack(df.to_msgpack())
Out[15]:
02013-01-0112013-01-0222013-01-033
[3rowsx1columns]
The text was updated successfully, but these errors were encountered:
A rare/corner case, but thought I'd document it.
pandas.read_msgpack() throws a
ValueError: Dates do not conform to passed frequency
if the index is a DatetimeIndex and there are only two rows of data.Adding a third row makes the problem go away:
The text was updated successfully, but these errors were encountered: