@@ -2121,9 +2121,11 @@ def info(self, verbose=None, buf=None, max_cols=None, memory_usage=None,
2121
2121
<class 'pandas.core.frame.DataFrame'>
2122
2122
RangeIndex: 5 entries, 0 to 4
2123
2123
Data columns (total 3 columns):
2124
- int_col 5 non-null int64
2125
- text_col 5 non-null object
2126
- float_col 5 non-null float64
2124
+ #. Column Non-Null Count
2125
+ --- ------ --------------
2126
+ 0 int_col 5 non-null int64
2127
+ 1 text_col 5 non-null object
2128
+ 2 float_col 5 non-null float64
2127
2129
dtypes: float64(1), int64(1), object(1)
2128
2130
memory usage: 200.0+ bytes
2129
2131
@@ -2161,19 +2163,23 @@ def info(self, verbose=None, buf=None, max_cols=None, memory_usage=None,
2161
2163
<class 'pandas.core.frame.DataFrame'>
2162
2164
RangeIndex: 1000000 entries, 0 to 999999
2163
2165
Data columns (total 3 columns):
2164
- column_1 1000000 non-null object
2165
- column_2 1000000 non-null object
2166
- column_3 1000000 non-null object
2166
+ #. Column Non-Null Count
2167
+ --- ------ --------------
2168
+ 0 column_1 1000000 non-null object
2169
+ 1 column_2 1000000 non-null object
2170
+ 2 column_3 1000000 non-null object
2167
2171
dtypes: object(3)
2168
2172
memory usage: 22.9+ MB
2169
2173
2170
2174
>>> df.info(memory_usage='deep')
2171
2175
<class 'pandas.core.frame.DataFrame'>
2172
2176
RangeIndex: 1000000 entries, 0 to 999999
2173
2177
Data columns (total 3 columns):
2174
- column_1 1000000 non-null object
2175
- column_2 1000000 non-null object
2176
- column_3 1000000 non-null object
2178
+ #. Column Non-Null Count
2179
+ --- ------ --------------
2180
+ 0 column_1 1000000 non-null object
2181
+ 1 column_2 1000000 non-null object
2182
+ 2 column_3 1000000 non-null object
2177
2183
dtypes: object(3)
2178
2184
memory usage: 188.8 MB
2179
2185
"""
@@ -2210,25 +2216,33 @@ def info(self, verbose=None, buf=None, max_cols=None, memory_usage=None,
2210
2216
def _verbose_repr ():
2211
2217
lines .append ('Data columns (total '
2212
2218
'{count} columns):' .format (count = cols_count ))
2213
- space = max ([len (pprint_thing (k )) for k in cols ])
2214
- space = max (space , len (pprint_thing ('Column' ))) + 4
2219
+ space = max (len (pprint_thing (k )) for k in cols )
2220
+ len_column = len (pprint_thing ('Column' ))
2221
+ space = max (space , len_column ) + 4
2215
2222
space_num = len (pprint_thing (cols_count ))
2216
- space_num = max (space_num , len (pprint_thing ('Index' ))) + 2
2223
+ len_id = len (pprint_thing (' #.' ))
2224
+ space_num = max (space_num , len_id ) + 2
2217
2225
counts = None
2218
2226
2219
- header = _put_str ('Index' , space_num ) + _put_str ('Column' , space )
2220
- tmpl = '{count}{dtype}'
2227
+ header = _put_str (' #.' , space_num ) + _put_str ('Column' , space )
2221
2228
if show_counts :
2222
2229
counts = self .count ()
2223
2230
if len (cols ) != len (counts ): # pragma: no cover
2224
2231
raise AssertionError (
2225
2232
'Columns must equal counts '
2226
2233
'({cols_count} != {count})' .format (
2227
2234
cols_count = cols_count , count = len (counts )))
2228
- header + = 'Non-Null Count'
2235
+ col_header = 'Non-Null Count'
2229
2236
tmpl = '{count} non-null {dtype}'
2237
+ else :
2238
+ col_header = 'dtype'
2239
+ tmpl = '{count}{dtype}'
2240
+ header += col_header
2230
2241
2231
2242
lines .append (header )
2243
+ lines .append (_put_str ('-' * len_id , space_num ) +
2244
+ _put_str ('-' * len_column , space ) +
2245
+ '-' * len (pprint_thing (col_header )))
2232
2246
dtypes = self .dtypes
2233
2247
for i , col in enumerate (cols ):
2234
2248
dtype = dtypes .iloc [i ]
0 commit comments