@@ -2232,6 +2232,89 @@ def to_html(
22322232 is used. By default, the setting in
22332233 ``pandas.options.display.max_info_columns`` is used.
22342234 """ ,
2235+ examples_sub = """
2236+ >>> int_values = [1, 2, 3, 4, 5]
2237+ >>> text_values = ['alpha', 'beta', 'gamma', 'delta', 'epsilon']
2238+ >>> float_values = [0.0, 0.25, 0.5, 0.75, 1.0]
2239+ >>> df = pd.DataFrame({"int_col": int_values, "text_col": text_values,
2240+ ... "float_col": float_values})
2241+ >>> df
2242+ int_col text_col float_col
2243+ 0 1 alpha 0.00
2244+ 1 2 beta 0.25
2245+ 2 3 gamma 0.50
2246+ 3 4 delta 0.75
2247+ 4 5 epsilon 1.00
2248+
2249+ Prints information of all columns:
2250+
2251+ >>> df.info(verbose=True)
2252+ <class 'pandas.core.frame.DataFrame'>
2253+ RangeIndex: 5 entries, 0 to 4
2254+ Data columns (total 3 columns):
2255+ # Column Non-Null Count Dtype
2256+ --- ------ -------------- -----
2257+ 0 int_col 5 non-null int64
2258+ 1 text_col 5 non-null object
2259+ 2 float_col 5 non-null float64
2260+ dtypes: float64(1), int64(1), object(1)
2261+ memory usage: 248.0+ bytes
2262+
2263+ Prints a summary of columns count and its dtypes but not per column
2264+ information:
2265+
2266+ >>> df.info(verbose=False)
2267+ <class 'pandas.core.frame.DataFrame'>
2268+ RangeIndex: 5 entries, 0 to 4
2269+ Columns: 3 entries, int_col to float_col
2270+ dtypes: float64(1), int64(1), object(1)
2271+ memory usage: 248.0+ bytes
2272+
2273+ Pipe output of DataFrame.info to buffer instead of sys.stdout, get
2274+ buffer content and writes to a text file:
2275+
2276+ >>> import io
2277+ >>> buffer = io.StringIO()
2278+ >>> df.info(buf=buffer)
2279+ >>> s = buffer.getvalue()
2280+ >>> with open("df_info.txt", "w",
2281+ ... encoding="utf-8") as f: # doctest: +SKIP
2282+ ... f.write(s)
2283+ 260
2284+
2285+ The `memory_usage` parameter allows deep introspection mode, specially
2286+ useful for big DataFrames and fine-tune memory optimization:
2287+
2288+ >>> random_strings_array = np.random.choice(['a', 'b', 'c'], 10 ** 6)
2289+ >>> df = pd.DataFrame({
2290+ ... 'column_1': np.random.choice(['a', 'b', 'c'], 10 ** 6),
2291+ ... 'column_2': np.random.choice(['a', 'b', 'c'], 10 ** 6),
2292+ ... 'column_3': np.random.choice(['a', 'b', 'c'], 10 ** 6)
2293+ ... })
2294+ >>> df.info()
2295+ <class 'pandas.core.frame.DataFrame'>
2296+ RangeIndex: 1000000 entries, 0 to 999999
2297+ Data columns (total 3 columns):
2298+ # Column Non-Null Count Dtype
2299+ --- ------ -------------- -----
2300+ 0 column_1 1000000 non-null object
2301+ 1 column_2 1000000 non-null object
2302+ 2 column_3 1000000 non-null object
2303+ dtypes: object(3)
2304+ memory usage: 22.9+ MB
2305+
2306+ >>> df.info(memory_usage='deep')
2307+ <class 'pandas.core.frame.DataFrame'>
2308+ RangeIndex: 1000000 entries, 0 to 999999
2309+ Data columns (total 3 columns):
2310+ # Column Non-Null Count Dtype
2311+ --- ------ -------------- -----
2312+ 0 column_1 1000000 non-null object
2313+ 1 column_2 1000000 non-null object
2314+ 2 column_3 1000000 non-null object
2315+ dtypes: object(3)
2316+ memory usage: 188.8 MB
2317+ """ ,
22352318 )
22362319 @Appender (NDFrame .info .__doc__ )
22372320 def info (
0 commit comments