@@ -1116,36 +1116,45 @@ def info(self, verbose=True, buf=None):
1116
1116
if buf is None : # pragma: no cover
1117
1117
buf = sys .stdout
1118
1118
1119
- print >> buf , str (type (self ))
1120
- print >> buf , self .index .summary ()
1119
+ def _put_lines (buf , lines ):
1120
+ if any (isinstance (x , unicode ) for x in lines ):
1121
+ lines = [unicode (x ) for x in lines ]
1122
+ print >> buf , '\n ' .join (lines )
1123
+
1124
+ lines = []
1125
+
1126
+ lines .append (str (type (self )))
1127
+ lines .append (self .index .summary ())
1121
1128
1122
1129
if len (self .columns ) == 0 :
1123
- print >> buf , 'Empty %s' % type (self ).__name__
1130
+ lines .append ('Empty %s' % type (self ).__name__ )
1131
+ _put_lines (buf , lines )
1124
1132
return
1125
1133
1126
1134
cols = self .columns
1127
1135
1128
1136
if verbose :
1129
- print >> buf , 'Data columns:'
1137
+ lines . append ( 'Data columns:' )
1130
1138
space = max ([len (_stringify (k )) for k in self .columns ]) + 4
1131
- col_counts = []
1132
1139
counts = self .count ()
1133
1140
assert (len (cols ) == len (counts ))
1134
1141
for col , count in counts .iteritems ():
1135
- colstr = _stringify (col )
1136
- col_counts .append ('%s%d non-null values' %
1137
- (_put_str (colstr , space ), count ))
1138
- print >> buf , '\n ' .join (col_counts )
1142
+ if not isinstance (col , (unicode , str )):
1143
+ col = str (col )
1144
+ # colstr = _stringify(col)
1145
+ lines .append (_put_str (col , space ) +
1146
+ '%d non-null values' % count )
1139
1147
else :
1140
1148
if len (cols ) <= 2 :
1141
- print >> buf , 'Columns: %s' % repr (cols )
1149
+ lines . append ( 'Columns: %s' % repr (cols ) )
1142
1150
else :
1143
- print >> buf , ('Columns: %s to %s' % (_stringify (cols [0 ]),
1144
- _stringify (cols [- 1 ])))
1151
+ lines . append ('Columns: %s to %s' % (_stringify (cols [0 ]),
1152
+ _stringify (cols [- 1 ])))
1145
1153
1146
1154
counts = self .get_dtype_counts ()
1147
1155
dtypes = ['%s(%d)' % k for k in sorted (counts .iteritems ())]
1148
- buf .write ('dtypes: %s' % ', ' .join (dtypes ))
1156
+ lines .append ('dtypes: %s' % ', ' .join (dtypes ))
1157
+ _put_lines (buf , lines )
1149
1158
1150
1159
@property
1151
1160
def dtypes (self ):
0 commit comments