@@ -194,14 +194,24 @@ def _get_column_formatter(self):
194
194
195
195
col_space = self .col_space
196
196
197
- def _myformat (v ):
198
- return _format (v , space = col_space , na_rep = self .na_rep ,
199
- float_format = self .float_format )
197
+ def _myformat (col ):
198
+ formatter = lambda v : _format (v , space = col_space ,
199
+ na_rep = self .na_rep ,
200
+ float_format = self .float_format )
201
+ # one pass through when float to stringify column, to pad with
202
+ # zeros
203
+ if issubclass (col .dtype .type , np .floating ):
204
+ col_width = max (map (len , map (formatter , col )))
205
+ formatter = lambda v : _format (v , space = col_space ,
206
+ na_rep = self .na_rep ,
207
+ float_format = self .float_format ,
208
+ col_width = col_width )
209
+ return formatter
200
210
201
211
formatters = {} if self .formatters is None else self .formatters
202
212
203
213
def _format_col (col , i = None ):
204
- formatter = formatters .get (col , _myformat )
214
+ formatter = formatters .get (col , _myformat ( self . frame [ col ]) )
205
215
if i == None :
206
216
return [formatter (x ) for x in self .frame [col ]]
207
217
else :
@@ -217,8 +227,7 @@ def _get_formatted_column_labels(self):
217
227
formatters = {}
218
228
219
229
def is_numeric_dtype (dtype ):
220
- return (issubclass (dtype .type , np .integer ) or
221
- issubclass (dtype .type , np .floating ))
230
+ return issubclass (dtype .type , np .number )
222
231
223
232
if isinstance (self .columns , MultiIndex ):
224
233
fmt_columns = self .columns .format (sparsify = False , adjoin = False )
0 commit comments