@@ -765,9 +765,9 @@ def copy(self, file, mode = 'w', propindexes = True, keys = None, complib = None
765
765
index = False
766
766
if propindexes :
767
767
index = [ a .name for a in s .axes if a .is_indexed ]
768
- new_store .append (k ,data , index = index , data_columns = getattr (s ,'data_columns' ,None ))
768
+ new_store .append (k , data , index = index , data_columns = getattr (s ,'data_columns' ,None ), encoding = s . encoding )
769
769
else :
770
- new_store .put (k ,data )
770
+ new_store .put (k , data , encoding = s . encoding )
771
771
772
772
return new_store
773
773
@@ -1043,13 +1043,13 @@ def convert(self, values, nan_rep, encoding):
1043
1043
1044
1044
kwargs = dict ()
1045
1045
if self .freq is not None :
1046
- kwargs ['freq' ] = self .freq
1046
+ kwargs ['freq' ] = _ensure_decoded ( self .freq )
1047
1047
if self .tz is not None :
1048
- kwargs ['tz' ] = self .tz
1048
+ kwargs ['tz' ] = _ensure_decoded ( self .tz )
1049
1049
if self .index_name is not None :
1050
- kwargs ['name' ] = self .index_name
1050
+ kwargs ['name' ] = _ensure_decoded ( self .index_name )
1051
1051
try :
1052
- self .values = Index (_maybe_convert (values , self .kind , encoding ), ** kwargs )
1052
+ self .values = Index (_maybe_convert (values , self .kind , self . encoding ), ** kwargs )
1053
1053
except :
1054
1054
1055
1055
# if the output freq is different that what we recorded, then infer it
@@ -1706,7 +1706,7 @@ def get_attrs(self):
1706
1706
""" retrieve our attributes """
1707
1707
self .encoding = _ensure_encoding (getattr (self .attrs ,'encoding' ,None ))
1708
1708
for n in self .attributes :
1709
- setattr (self ,n ,getattr (self .attrs , n , None ))
1709
+ setattr (self ,n ,_ensure_decoded ( getattr (self .attrs , n , None ) ))
1710
1710
1711
1711
def write (self , obj , ** kwargs ):
1712
1712
self .set_attrs ()
@@ -1847,7 +1847,7 @@ def read_multi_index(self, key):
1847
1847
1848
1848
def read_index_node (self , node ):
1849
1849
data = node [:]
1850
- kind = node ._v_attrs .kind
1850
+ kind = _ensure_decoded ( node ._v_attrs .kind )
1851
1851
name = None
1852
1852
1853
1853
if 'name' in node ._v_attrs :
@@ -1858,13 +1858,13 @@ def read_index_node(self, node):
1858
1858
factory = self ._get_index_factory (index_class )
1859
1859
1860
1860
kwargs = {}
1861
- if 'freq' in node ._v_attrs :
1861
+ if u 'freq' in node ._v_attrs :
1862
1862
kwargs ['freq' ] = node ._v_attrs ['freq' ]
1863
1863
1864
- if 'tz' in node ._v_attrs :
1864
+ if u 'tz' in node ._v_attrs :
1865
1865
kwargs ['tz' ] = node ._v_attrs ['tz' ]
1866
1866
1867
- if kind in ('date' , 'datetime' ):
1867
+ if kind in (u 'date' , u 'datetime' ):
1868
1868
index = factory (_unconvert_index (data , kind , encoding = self .encoding ), dtype = object ,
1869
1869
** kwargs )
1870
1870
else :
@@ -2077,7 +2077,7 @@ def write(self, obj, **kwargs):
2077
2077
self .attrs .default_kind = obj .default_kind
2078
2078
self .write_index ('items' , obj .items )
2079
2079
2080
- for name , sdf in obj .iteritems ():
2080
+ for name , sdf in obj .iterkv ():
2081
2081
key = 'sparse_frame_%s' % name
2082
2082
if key not in self .group ._v_children :
2083
2083
node = self ._handle .createGroup (self .group , key )
@@ -3358,7 +3358,8 @@ def _get_converter(kind, encoding):
3358
3358
raise ValueError ('invalid kind %s' % kind )
3359
3359
3360
3360
def _need_convert (kind ):
3361
- if kind in ('datetime' , 'datetime64' , 'string' ):
3361
+ kind = _ensure_decoded (kind )
3362
+ if kind in (u'datetime' , u'datetime64' , u'string' ):
3362
3363
return True
3363
3364
return False
3364
3365
@@ -3464,7 +3465,7 @@ def __init__(self, field, op=None, value=None, queryables=None, i=None, encoding
3464
3465
3465
3466
# we have valid conditions
3466
3467
if self .op in ['>' , '>=' , '<' , '<=' ]:
3467
- if hasattr (self .value , '__iter__' ) and len (self .value ) > 1 :
3468
+ if hasattr (self .value , '__iter__' ) and len (self .value ) > 1 and not isinstance ( self . value , basestring ) :
3468
3469
raise ValueError ("an inequality condition cannot have multiple values [%s]" % str (self ))
3469
3470
3470
3471
if not is_list_like (self .value ):
@@ -3559,7 +3560,7 @@ def stringify(value):
3559
3560
value = value .encode (self .encoding )
3560
3561
return value
3561
3562
3562
- kind = self .kind
3563
+ kind = _ensure_decoded ( self .kind )
3563
3564
if kind == u'datetime64' or kind == u'datetime' :
3564
3565
v = lib .Timestamp (v )
3565
3566
if v .tz is not None :
@@ -3576,7 +3577,7 @@ def stringify(value):
3576
3577
return TermValue (v ,v ,kind )
3577
3578
elif kind == u'bool' :
3578
3579
if isinstance (v , basestring ):
3579
- v = not stringify ( v ) .strip ().lower () in [u'false' , u'f' , u'no' , u'n' , u'none' , u'0' , u'[]' , u'{}' , u'' ]
3580
+ v = not v .strip ().lower () in [u'false' , u'f' , u'no' , u'n' , u'none' , u'0' , u'[]' , u'{}' , u'' ]
3580
3581
else :
3581
3582
v = bool (v )
3582
3583
return TermValue (v ,v ,kind )
0 commit comments