| 
55 | 55 | from pandas import (Timestamp, Period, Series, DataFrame,  # noqa  | 
56 | 56 |                     Index, MultiIndex, Float64Index, Int64Index,  | 
57 | 57 |                     Panel, RangeIndex, PeriodIndex, DatetimeIndex, NaT,  | 
58 |  | -                    Categorical, CategoricalIndex)  | 
 | 58 | +                    Categorical, CategoricalIndex, IntervalIndex, Interval,  | 
 | 59 | +                    TimedeltaIndex)  | 
59 | 60 | from pandas.core.sparse.api import SparseSeries, SparseDataFrame  | 
60 | 61 | from pandas.core.sparse.array import BlockIndex, IntIndex  | 
61 | 62 | from pandas.core.generic import NDFrame  | 
@@ -401,6 +402,13 @@ def encode(obj):  | 
401 | 402 |                     u'freq': u_safe(getattr(obj, 'freqstr', None)),  | 
402 | 403 |                     u'tz': tz,  | 
403 | 404 |                     u'compress': compressor}  | 
 | 405 | +        elif isinstance(obj, IntervalIndex):  | 
 | 406 | +            return {u'typ': u'interval_index',  | 
 | 407 | +                    u'klass': u(obj.__class__.__name__),  | 
 | 408 | +                    u'name': getattr(obj, 'name', None),  | 
 | 409 | +                    u'left': getattr(obj, '_left', None),  | 
 | 410 | +                    u'right': getattr(obj, '_right', None),  | 
 | 411 | +                    u'closed': getattr(obj, '_closed', None)}  | 
404 | 412 |         elif isinstance(obj, MultiIndex):  | 
405 | 413 |             return {u'typ': u'multi_index',  | 
406 | 414 |                     u'klass': u(obj.__class__.__name__),  | 
@@ -513,7 +521,12 @@ def encode(obj):  | 
513 | 521 |     elif isinstance(obj, Period):  | 
514 | 522 |         return {u'typ': u'period',  | 
515 | 523 |                 u'ordinal': obj.ordinal,  | 
516 |  | -                u'freq': u(obj.freq)}  | 
 | 524 | +                u'freq': u_safe(obj.freqstr)}  | 
 | 525 | +    elif isinstance(obj, Interval):  | 
 | 526 | +        return {u'typ': u'interval',  | 
 | 527 | +                u'left': obj.left,  | 
 | 528 | +                u'right': obj.right,  | 
 | 529 | +                u'closed': obj.closed}  | 
517 | 530 |     elif isinstance(obj, BlockIndex):  | 
518 | 531 |         return {u'typ': u'block_index',  | 
519 | 532 |                 u'klass': u(obj.__class__.__name__),  | 
@@ -597,12 +610,19 @@ def decode(obj):  | 
597 | 610 |             result = result.tz_localize('UTC').tz_convert(tz)  | 
598 | 611 |         return result  | 
599 | 612 | 
 
  | 
 | 613 | +    elif typ == u'interval_index':  | 
 | 614 | +        return globals()[obj[u'klass']].from_arrays(obj[u'left'],  | 
 | 615 | +                                                    obj[u'right'],  | 
 | 616 | +                                                    obj[u'closed'],  | 
 | 617 | +                                                    name=obj[u'name'])  | 
600 | 618 |     elif typ == u'category':  | 
601 | 619 |         from_codes = globals()[obj[u'klass']].from_codes  | 
602 | 620 |         return from_codes(codes=obj[u'codes'],  | 
603 | 621 |                           categories=obj[u'categories'],  | 
604 | 622 |                           ordered=obj[u'ordered'])  | 
605 | 623 | 
 
  | 
 | 624 | +    elif typ == u'interval':  | 
 | 625 | +        return Interval(obj[u'left'], obj[u'right'], obj[u'closed'])  | 
606 | 626 |     elif typ == u'series':  | 
607 | 627 |         dtype = dtype_for(obj[u'dtype'])  | 
608 | 628 |         pd_dtype = pandas_dtype(dtype)  | 
 | 
0 commit comments