@@ -1392,17 +1392,20 @@ def to_latex(self, buf=None, columns=None, col_space=None, colSpace=None,
1392
1392
if buf is None :
1393
1393
return formatter .buf .getvalue ()
1394
1394
1395
- def info (self , verbose = True , buf = None , max_cols = None ):
1395
+ def info (self , verbose = None , buf = None , max_cols = None ):
1396
1396
"""
1397
1397
Concise summary of a DataFrame.
1398
1398
1399
1399
Parameters
1400
1400
----------
1401
- verbose : boolean, default True
1402
- If False, don't print column count summary
1401
+ verbose : {None, True, False}, optional
1402
+ Whether to print the full summary.
1403
+ None follows the `display.max_info_columns` setting.
1404
+ True or False overrides the `display.max_info_columns` setting.
1403
1405
buf : writable buffer, defaults to sys.stdout
1404
1406
max_cols : int, default None
1405
- Determines whether full summary or short summary is printed
1407
+ Determines whether full summary or short summary is printed.
1408
+ None follows the `display.max_info_columns` setting.
1406
1409
"""
1407
1410
from pandas .core .format import _put_lines
1408
1411
@@ -1429,8 +1432,10 @@ def info(self, verbose=True, buf=None, max_cols=None):
1429
1432
max_rows = get_option ('display.max_info_rows' , len (self ) + 1 )
1430
1433
1431
1434
show_counts = ((len (self .columns ) <= max_cols ) and
1432
- (len (self ) < max_rows ))
1433
- if verbose :
1435
+ (len (self ) < max_rows ))
1436
+ exceeds_info_cols = len (self .columns ) > max_cols
1437
+
1438
+ def _verbose_repr ():
1434
1439
lines .append ('Data columns (total %d columns):' %
1435
1440
len (self .columns ))
1436
1441
space = max ([len (com .pprint_thing (k )) for k in self .columns ]) + 4
@@ -1442,22 +1447,33 @@ def info(self, verbose=True, buf=None, max_cols=None):
1442
1447
if len (cols ) != len (counts ): # pragma: no cover
1443
1448
raise AssertionError ('Columns must equal counts (%d != %d)' %
1444
1449
(len (cols ), len (counts )))
1445
- tmpl = "%s non-null %s"
1450
+ tmpl = "%s non-null %s"
1446
1451
1447
1452
dtypes = self .dtypes
1448
1453
for i , col in enumerate (self .columns ):
1449
1454
dtype = dtypes [col ]
1450
1455
col = com .pprint_thing (col )
1451
1456
1452
- count = ""
1457
+ count = ""
1453
1458
if show_counts :
1454
1459
count = counts .iloc [i ]
1455
1460
1456
1461
lines .append (_put_str (col , space ) +
1457
1462
tmpl % (count , dtype ))
1458
- else :
1463
+
1464
+ def _non_verbose_repr ():
1459
1465
lines .append (self .columns .summary (name = 'Columns' ))
1460
1466
1467
+ if verbose :
1468
+ _verbose_repr ()
1469
+ elif verbose is False : # specifically set to False, not nesc None
1470
+ _non_verbose_repr ()
1471
+ else :
1472
+ if exceeds_info_cols :
1473
+ _non_verbose_repr ()
1474
+ else :
1475
+ _verbose_repr ()
1476
+
1461
1477
counts = self .get_dtype_counts ()
1462
1478
dtypes = ['%s(%d)' % k for k in sorted (compat .iteritems (counts ))]
1463
1479
lines .append ('dtypes: %s' % ', ' .join (dtypes ))
0 commit comments