Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Pandas · Module

df.info

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.

How it works

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.

Syntax

DataFrame.info(verbose=None, buf=None, max_cols=None, memory_usage=None, show_counts=None)

Parameters

NameTypeDescription
verbosebool, optionalWhether to print the full summary; defaults to the relevant display option.
bufwritable buffer, optionalWritable destination for output; defaults to sys.stdout.
max_colsint, optionalColumn count at which output changes to truncated form; defaults to the relevant display option.
memory_usagebool or str, optionalControls memory reporting: True, False, or 'deep'; defaults to the relevant display setting.
show_countsbool, optionalWhether to display non-null counts; defaults according to the relevant display thresholds.

Returns

None

Key points

  • Use this method for a quick structural overview during data exploration or debugging.
  • The report combines index dtype, column metadata, non-null information, and memory usage.
  • Calling the method normally writes the diagnostic text to standard output.
  • Provide buf when the report must be captured or sent somewhere other than the console.
  • Set show_counts to choose whether per-column non-null counts appear.
  • Use memory_usage to include or suppress total element-and-index memory usage.

Common mistakes

  • Non-null counts may be omitted for large DataFrames unless show_counts=True.
  • Use memory_usage="deep" when object columns need deeper memory accounting; it can be more expensive than the default estimate.

Example: Inspect a DataFrame

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.

When to use it

Schema inspection

Quickly verify column names, inferred dtypes, and missing-value presence after loading or transforming data.

Memory diagnostics

Identify unexpectedly large object columns or overall frame footprint during memory troubleshooting.

Redirected reporting

Capture a reproducible structural report in a log or test artifact by passing a writable buffer.

Interview questions

QWhat does 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.

QWhere does the output go, and how can it be redirected?

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.

QHow do 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.dtypes
  • DataFrame.memory_usage
  • DataFrame.describe
  • DataFrame.shape

Source: pandas.DataFrame.info. Checked 2026-10-15.