Schema inspection
Quickly verify column names, inferred dtypes, and missing-value presence after loading or transforming data.
Pandas · Module
Print a concise diagnostic summary of a pandas DataFrame, including its index, columns, dtypes, non-null counts, and memory usage. Output is written to standard output unless redirected.
Call DataFrame.info to print a compact diagnostic report containing the index, columns, data types, non-null counts, and memory usage. Output goes to standard output by default, or to a supplied writable buffer; options control detail, column truncation, counts, and memory reporting.
DataFrame.info(verbose=None, buf=None, max_cols=None, memory_usage=None, show_counts=None)| Name | Type | Description |
|---|---|---|
verbose | bool, optional | Whether to print the full summary; defaults to the relevant display option. |
buf | writable buffer, optional | Writable destination for output; defaults to sys.stdout. |
max_cols | int, optional | Column count at which output changes to truncated form; defaults to the relevant display option. |
memory_usage | bool or str, optional | Controls memory reporting: True, False, or 'deep'; defaults to the relevant display setting. |
show_counts | bool, optional | Whether to display non-null counts; defaults according to the relevant display thresholds. |
None
buf when the report must be captured or sent somewhere other than the console.show_counts to choose whether per-column non-null counts appear.memory_usage to include or suppress total element-and-index memory usage.show_counts=True.memory_usage="deep" when object columns need deeper memory accounting; it can be more expensive than the default estimate.import pandas as pd
sales = pd.DataFrame({
"item": ["book", "pen", "book"],
"price": [12.5, 2.0, None],
})
sales.info(show_counts=True, memory_usage="deep")Prints the DataFrame schema, non-null counts, and detailed memory usage.
Quickly verify column names, inferred dtypes, and missing-value presence after loading or transforming data.
Identify unexpectedly large object columns or overall frame footprint during memory troubleshooting.
Capture a reproducible structural report in a log or test artifact by passing a writable buffer.
DataFrame.info() provide?DataFrame.info() prints a concise summary rather than returning another DataFrame. The report includes index information, column names and dtypes, non-NA counts, and memory usage.
Follow-up: How would you inspect a large frame while guaranteeing counts? Pass show_counts=True; use memory_usage=False if memory reporting is unnecessary.
By default, output is written to sys.stdout. Pass a writable buffer through buf to capture or redirect the report for further processing.
Follow-up: How could you capture the text in memory? Supply an io.StringIO instance as buf, then read its value.
verbose and max_cols affect the report?verbose controls whether the full summary is printed. max_cols controls when pandas switches to truncated output; without explicit values, the corresponding display options determine the behavior.
Follow-up: What controls the default threshold? pandas.options.display.max_info_columns determines the default column threshold.
DataFrame.dtypesDataFrame.memory_usageDataFrame.describeDataFrame.shape