@@ -46,10 +46,6 @@ def slice_naive(self, key):
4646 key = check_key (self , key )
4747 return cls (self .loc [key ])
4848
49- def __repr__ (self ):
50- name = '.' .join ([self .__module__ , self .__class__ .__name__ ])
51- return '{0}{1}' .format (name , self .shape )
52-
5349 def __str__ (self ):
5450 return self .__repr__ ()
5551
@@ -193,13 +189,20 @@ def copy(self, *args, **kwargs):
193189 cls = self .__class__ # Note that type conversion does not perform copy
194190 return cls (pd .DataFrame (self ).copy (* args , ** kwargs ))
195191
196- def _revert_categories (self ):
192+ def _revert_categories (self , inplace = True ):
197193 """
198194 Inplace conversion to categories.
199195 """
200- for column , dtype in self ._categories .items ():
201- if column in self .columns :
202- self [column ] = self [column ].astype (dtype )
196+ if inplace :
197+ for column , dtype in self ._categories .items ():
198+ if column in self .columns :
199+ self [column ] = self [column ].astype (dtype )
200+ else :
201+ copy = self .copy ()
202+ for column , dtype in copy ._categories .items ():
203+ if column in copy .columns :
204+ copy [column ] = copy [column ].astype (dtype )
205+ return copy
203206
204207 def _set_categories (self ):
205208 """
0 commit comments