Skip to content

BUG: read_pickle and period data #10439

Closed
@scarrucciu

Description

@scarrucciu

I can pickle dataframes with periods but after import Period format becomes corrupted. After pickle Period stride appears to be none instead of 'Q' in the following example.


import pandas as pd

df = pd.DataFrame({'period': [pd.Period('2014Q4')] * 5})
msk = df['period'] == pd.Period('2014Q4')
print msk

df.to_pickle('tmp.pkl')
df = pd.read_pickle('tmp.pkl')

msk = df['period'] == pd.Period('2014Q4')

Traceback (most recent call last):
  File "/Users/scarrucciu/Downloads/period_pickle_test.py", line 11, in 
    msk = df['period'] == pd.Period('2014Q4')
  File "/Users/scarrucciu/anaconda/lib/python2.7/site-packages/pandas/core/ops.py", line 614, in wrapper
    res = na_op(values, other)
  File "/Users/scarrucciu/anaconda/lib/python2.7/site-packages/pandas/core/ops.py", line 562, in na_op
    result = lib.scalar_compare(x, y, op)
  File "pandas/lib.pyx", line 696, in pandas.lib.scalar_compare (pandas/lib.c:12434)
  File "das/src/period.pyx", line 743, in pandas._period.Period.__richcmp__ (pandas/src/period.c:11121)
ValueError: Cannot compare non-conforming periods

INSTALLED VERSIONS

commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Darwin
OS-release: 13.4.0
machine: x86_64
processor: i386
byteorder: little
pandas: 0.16.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Compatpandas objects compatability with Numpy or Python functionsPeriodPeriod data type

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions