1717along with datamatrix. If not, see <http://www.gnu.org/licenses/>.
1818"""
1919
20- import warnings
21- from datamatrix import Row
20+ from datamatrix import Row , utils
2221from datamatrix ._datamatrix ._basecolumn import BaseColumn
2322from datamatrix ._datamatrix ._mixedcolumn import MixedColumn
2423from datamatrix ._datamatrix ._index import Index
@@ -166,9 +165,9 @@ def column_names(self):
166165
167166 Use DataMatrix.columns instead.
168167 """
169- warnings . warn (
168+ utils . logger . warning (
170169 'DataMatrix.column_names is deprecated, use DataMatrix.columns '
171- 'instead' , DeprecationWarning )
170+ 'instead' )
172171 return self ._to_list (self ._cols .keys ())
173172
174173 @property
@@ -529,7 +528,7 @@ def _getcolbyname(self, key):
529528 """
530529
531530 if isinstance (key , bytes ):
532- key = safe_decode (key )
531+ key = utils . safe_decode (key )
533532 col = self ._cols .get (key , None )
534533 if col is None :
535534 raise AttributeError (u'No column named "%s"' % key )
@@ -587,7 +586,7 @@ def _set_col(self, name, value):
587586
588587 # Check if this is a valid column name
589588 if isinstance (name , bytes ):
590- name = safe_decode (name )
589+ name = utils . safe_decode (name )
591590 if not isinstance (name , str ):
592591 raise TypeError (u'Column names should be str, not %s' % type (name ))
593592 # Create a new column by column type:
@@ -753,7 +752,7 @@ def __delattr__(self, name):
753752 def __setattr__ (self , name , value ):
754753
755754 if isinstance (name , bytes ):
756- name = safe_decode (name )
755+ name = utils . safe_decode (name )
757756 if name == u'length' :
758757 self ._setlength (value )
759758 return
@@ -900,12 +899,6 @@ def __array__(self, *args):
900899 pass
901900 return a
902901
903- def __dataframe__ (self ):
904-
905- from datamatrix import convert as cnv
906-
907- return cnv .to_pandas (self )
908-
909902 def _instantiate (self ):
910903 """Instantiates all uninstantiated columns"""
911904 for name , col in self ._cols .items ():
@@ -924,3 +917,11 @@ def _instantiate_column(self, key, col=None):
924917 col = col .instantiate ()
925918 self ._cols [key ] = col
926919 return col
920+
921+ # The functions below mimic the pandas.DataFrame API
922+
923+ def __dataframe__ (self ):
924+
925+ from datamatrix import convert as cnv
926+
927+ return cnv .to_pandas (self )
0 commit comments