@@ -1751,45 +1751,46 @@ def info(self, verbose=None, buf=None, max_cols=None, memory_usage=None,
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 %d columns):' % cols_count )
1771
+ space = max ([ len ( pprint_thing ( k )) for k in cols ]) + 4
1772
+ space_num = len (pprint_thing (cols_count )) + 2
1773
1773
counts = None
1774
1774
1775
1775
tmpl = "%s%s"
1776
1776
if show_counts :
1777
1777
counts = self .count ()
1778
1778
if len (cols ) != len (counts ): # pragma: no cover
1779
1779
raise AssertionError ('Columns must equal counts (%d != %d)'
1780
- % (len ( cols ) , len (counts )))
1780
+ % (cols_count , len (counts )))
1781
1781
tmpl = "%s non-null %s"
1782
1782
1783
1783
dtypes = self .dtypes
1784
- for i , col in enumerate (self . columns ):
1784
+ for i , col in enumerate (cols ):
1785
1785
dtype = dtypes .iloc [i ]
1786
1786
col = pprint_thing (col )
1787
-
1787
+ line_no = ( "%d. " % ( i + 1 )). rjust ( space_num )
1788
1788
count = ""
1789
1789
if show_counts :
1790
1790
count = counts .iloc [i ]
1791
1791
1792
- lines .append (_put_str (col , space ) + tmpl % (count , dtype ))
1792
+ lines .append (line_no + _put_str (col , space ) +
1793
+ tmpl % (count , dtype ))
1793
1794
1794
1795
def _non_verbose_repr ():
1795
1796
lines .append (self .columns .summary (name = 'Columns' ))
0 commit comments