Unlike most DataFrame methods, info() doesn't return a value you'd assign to a variable — it prints its summary directly and returns None, so it's meant to be called on its own line purely for its side effect of displaying diagnostic information. The non-null count per column is one of its most useful pieces of information: comparing it against the DataFrame's total row count immediately reveals which columns have missing data, without needing a separate isna().sum() call.
1Understanding df.info()
Unlike most DataFrame methods, info() doesn't return a value you'd assign to a variable — it prints its summary directly and returns None, so it's meant to be called on its own line purely for its side effect of displaying diagnostic information. The non-null count per column is one of its most useful pieces of information: comparing it against the DataFrame's total row count immediately reveals which columns have missing data, without needing a separate isna().sum() call.
df.info() returns None — don't try to assign its result to a variable or otherwise use it programmatically; it's meant purely for the side effect of printing a summary to the console.
import pandas as pd
import numpy as np
df = pd.DataFrame({"a": [1, 2, np.nan], "b": ["x", "y", "z"]})
df.info()2Practical Example
Here is a real-world application of df.info() showing how it is used in production Pandas code.
import pandas as pd
df = pd.DataFrame({"a": [1, 2, 3]})
result = df.info()
print(result)3Best Practices
Follow these guidelines when working with df.info():
1. Call df.info() right after loading a dataset, alongside head(), to quickly see dtypes and spot columns with missing data
2. Compare info()'s non-null counts per column against the total row count to spot missing data at a glance, without a separate isna() call
3. Pass memory_usage='deep' for a more accurate memory estimate specifically when the DataFrame has object-dtype columns, like strings, whose true memory use info()'s default shallow estimate can understate
Tip: df.info() returns None — don't try to assign its result to a variable or otherwise use it programmatically; it's meant purely for the side effect of printing a summary to the console.
import pandas as pd
import numpy as np
df = pd.DataFrame({"a": [1, 2, np.nan], "b": ["x", "y", "z"]})
df.info()