@@ -1746,50 +1746,54 @@ def info(self, verbose=None, buf=None, max_cols=None, memory_usage=None,
1746
1746
lines .append (self .index .summary ())
1747
1747
1748
1748
if len (self .columns ) == 0 :
1749
- lines .append ('Empty %s' % type (self ).__name__ )
1749
+ lines .append ('Empty {name}' . format ( name = type (self ).__name__ ) )
1750
1750
_put_lines (buf , lines )
1751
1751
return
1752
1752
1753
1753
cols = self .columns
1754
+ cols_count = len (cols )
1754
1755
1755
1756
# hack
1756
1757
if max_cols is None :
1757
- max_cols = get_option ('display.max_info_columns' ,
1758
- len (self .columns ) + 1 )
1758
+ max_cols = get_option ('display.max_info_columns' , cols_count + 1 )
1759
1759
1760
1760
max_rows = get_option ('display.max_info_rows' , len (self ) + 1 )
1761
1761
1762
1762
if null_counts is None :
1763
- show_counts = ((len ( self . columns ) <= max_cols ) and
1763
+ show_counts = ((cols_count <= max_cols ) and
1764
1764
(len (self ) < max_rows ))
1765
1765
else :
1766
1766
show_counts = null_counts
1767
- exceeds_info_cols = len ( self . columns ) > max_cols
1767
+ exceeds_info_cols = cols_count > max_cols
1768
1768
1769
1769
def _verbose_repr ():
1770
- lines .append ('Data columns (total %d columns):' %
1771
- len (self .columns ))
1772
- space = max ([len (pprint_thing (k )) for k in self .columns ]) + 4
1770
+ lines .append ('Data columns (total '
1771
+ '{count} columns):' .format (count = cols_count ))
1772
+ space = max ([len (pprint_thing (k )) for k in cols ]) + 4
1773
+ space_num = len (pprint_thing (cols_count )) + 2
1773
1774
counts = None
1774
1775
1775
- tmpl = "%s%s"
1776
+ tmpl = '{count}{dtype}'
1776
1777
if show_counts :
1777
1778
counts = self .count ()
1778
1779
if len (cols ) != len (counts ): # pragma: no cover
1779
- raise AssertionError ('Columns must equal counts (%d != %d)'
1780
- % (len (cols ), len (counts )))
1781
- tmpl = "%s non-null %s"
1780
+ raise AssertionError (
1781
+ 'Columns must equal counts '
1782
+ '({cols_count} != {count})' .format (
1783
+ cols_count = cols_count , count = len (counts )))
1784
+ tmpl = '{count} non-null {dtype}'
1782
1785
1783
1786
dtypes = self .dtypes
1784
- for i , col in enumerate (self . columns ):
1787
+ for i , col in enumerate (cols ):
1785
1788
dtype = dtypes .iloc [i ]
1786
1789
col = pprint_thing (col )
1787
-
1788
- count = ""
1790
+ line_no = '{num}. ' . format ( num = i + 1 ). rjust ( space_num )
1791
+ count = ''
1789
1792
if show_counts :
1790
1793
count = counts .iloc [i ]
1791
1794
1792
- lines .append (_put_str (col , space ) + tmpl % (count , dtype ))
1795
+ lines .append (line_no + _put_str (col , space ) +
1796
+ tmpl .format (count = count , dtype = dtype ))
1793
1797
1794
1798
def _non_verbose_repr ():
1795
1799
lines .append (self .columns .summary (name = 'Columns' ))
0 commit comments