Use splitlines for lists, then indexig for remove first 5 values and last 2 and split by space with DataFrame constructor:

import io
buffer = io.StringIO()
df.info(buf=buffer)
lines = buffer.getvalue().splitlines()
df = (pd.DataFrame([x.split() for x in lines[5:-2]], columns=lines[3].split())
       .drop('Count',axis=1)
       .rename(columns={'Non-Null':'Non-Null Count'}))
print (df)
Answer from jezrael on Stack Overflow
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.DataFrame.info.html
pandas.DataFrame.info โ€” pandas 3.0.2 documentation
This method prints information about a DataFrame including the index dtype and columns, non-NA values and memory usage. ... Whether to print the full summary. By default, the setting in pandas.options.display.max_info_columns is followed.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-pandas-dataframe-info
Python | Pandas dataframe.info() - GeeksforGeeks
July 26, 2025 - Python ยท import pandas as pd df = pd.read_csv("/content/nba.csv") df.info() Output : Here info() provides an overview of the DataFrame's structure such as number of entries, column names, data types and non-null counts.
Discussions

python - How to save Pandas info() function output to variable or data frame - Stack Overflow
How to save Pandas df.info() function output to variable or data frame? More on stackoverflow.com
๐ŸŒ stackoverflow.com
python 3.x - how to convert df.info() into data frame. df.info() - Stack Overflow
Use df.info() to extract the column information. Programmatically extract the non-null counts and data types for each column. Store the extracted data in a structured format such as a list of dictionaries (or a DataFrame). ... import pandas as pd # Assuming `df` is your DataFrame def ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Df.info() is not displaying any result in st.write()
Hi, I am trying to get information of pandas dataframe using the following code: st.write(df.info()) But instead of printing information of dataframe it is printing โ€œNoneโ€ and the result is printed in command prompt instead. Help me in resolving this issue. More on discuss.streamlit.io
๐ŸŒ discuss.streamlit.io
1
0
August 21, 2020
Call to DataFrame.info() causes huge memory consumption. Why?
I don't have a super confident answer here, or at least I can't tell you precisely how much RAM you should expect to evaporate. But info computes a bunch of descriptive statistics, and your df has almost 3 million records. So a very large spike in memory when crunching stats on such a large data set doesn't seem too surprising. N'est-ce pas? More on reddit.com
๐ŸŒ r/learnpython
2
9
February 25, 2022
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ pandas โ€บ ref_df_info.asp
Pandas DataFrame info() Method
import pandas as pd df = pd.read_csv('data.csv') df.info() Try it Yourself ยป ยท The info() method prints information about the DataFrame. The information contains the number of columns, column labels, column data types, memory usage, range ...
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ pandas โ€บ methods โ€บ info
Pandas info()
This summary includes information about the index data type and column data types, non-null values, and memory usage. import pandas as pd # sample DataFrame data = {'A': [1, 2, None], 'B': ['X', 'Y', 'Z']} df = pd.DataFrame(data) # get info df_info = df.info() ''' Output <class 'pandas.core.frame.DataFrame'> RangeIndex: 3 entries, 0 to 2 Data columns (total 2 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 A 2 non-null float64 1 B 3 non-null object dtypes: float64(1), object(1) memory usage: 180.0+ bytes ''' The syntax of the info() method in Pandas is: df.info(verbose=None, buf=None, max_cols=None, memory_usage=None, show_counts=None) The info() method has the following arguments: verbose (optional): whether to print the full summary ยท
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ python โ€บ third-party โ€บ pandas โ€บ DataFrame โ€บ info
Python Pandas DataFrame info() - Display Information | Vultr Docs
November 25, 2024 - Call the info() method to view the summary of the DataFrame. ... import pandas as pd data = {'Name': ['John', 'Anna', 'Peter', 'Linda'], 'Age': [28, 22, 34, 42], 'City': ['New York', 'Paris', 'Berlin', 'London']} df = pd.DataFrame(data) df.info() ...
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.DataFrame.html
pandas.DataFrame โ€” pandas 3.0.2 documentation
Data structure also contains labeled axes (rows and columns). Arithmetic operations align on both row and column labels. Can be thought of as a dict-like container for Series objects. The primary pandas data structure.
๐ŸŒ
Snowflake Documentation
docs.snowflake.com โ€บ en โ€บ developer-guide โ€บ snowpark โ€บ reference โ€บ python โ€บ 1.19.0 โ€บ modin โ€บ pandas_api โ€บ snowflake.snowpark.modin.pandas.DataFrame.info
modin.pandas.DataFrame.info | Snowflake Documentation
By default, this is shown only if the DataFrame is smaller than pandas.options.display.max_info_rows and pandas.options.display.max_info_columns. A value of True always shows the counts, and False never shows the counts. ... This method prints a summary of a DataFrame and returns None. ... >>> df.info() <class 'snowflake.snowpark.modin.pandas.dataframe.DataFrame'> SnowflakeIndex Data columns (total 2 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 COL1 3 non-null int64 1 COL2 3 non-null object dtypes: int64(1), object(1) memory usage: 0.0 bytes
Find elsewhere
Top answer
1 of 4
4

Building off of the previous answer. The solution below will place the string collected from the buffer directly into a pandas DataFrame without having to save a temp file to disk

import io
buf = io.StringIO()
df.info(buf=buf)
s = buf.getvalue()
lines = [line.split() for line in s.splitlines()[3:-2]]
pd.DataFrame(lines)

Explaination:

  • s.splitlines() - creates a list from the string where a new line character is found
  • indexing [3:-2] - removes the first three lines and last two so that it will fit nicely into columns for the data frame
2 of 4
2

While the info() method directly prints the information to the output, and even when you use the buffer to extract the info, it extracts it in the form of text lines, which are hardly useful for further processing.

The above mentioned solution does work, but it creates a problem when your column names have spaces or are inconsistently named for you to be able to use the line.split() with some other separator character.

I couldn't search of any way to do this using the default info() method. So, I made my own function to do this. And it is not that complicated.

def infoOut(data,details=False):
    dfInfo = data.columns.to_frame(name='Column')
    dfInfo['Non-Null Count'] = data.notna().sum()
    dfInfo['Dtype'] = data.dtypes
    dfInfo.reset_index(drop=True,inplace=True)
    if details:
        rangeIndex = (dfInfo['Non-Null Count'].min(),dfInfo['Non-Null Count'].min())
        totalColumns = dfInfo['Column'].count()
        dtypesCount = dfInfo['Dtype'].value_counts()
        totalMemory = dfInfo.memory_usage().sum()
        return dfInfo, rangeIndex, totalColumns, dtypesCount, totalMemory
    else:
        return dfInfo

Usage:

variable = infoOut(yourDataFrameObject)
#or
var1, var2, var3, var4, var5 = infoOut(yourDataFrameObject,details=True)

This function will return the exact table structure as returned by the info method for your supplied dataframe, and that too in a dataframe format. Further, if you supply with an argument details=True, then it will also give our other information that info() gives out like memory, summary counts, etc.

Modify the function as you like.

Good day.

๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ pandas โ€บ pandas dataframe info() function
Pandas DataFrame info() Function - Spark By {Examples}
July 29, 2024 - Instead, it prints a summary of the DataFrame to the console or the specified buffer. This summary includes details such as the number of non-null entries, data types of the columns, and memory usage.
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ user_guide โ€บ gotchas.html
Frequently Asked Questions (FAQ) โ€” pandas 3.0.2 documentation
In [1]: dtypes = [ ...: "int64", ...: "float64", ...: "datetime64[ns]", ...: "timedelta64[ns]", ...: "complex128", ...: "object", ...: "bool", ...: ] ...: In [2]: n = 5000 In [3]: data = {t: np.random.randint(100, size=n).astype(t) for t in dtypes} In [4]: df = pd.DataFrame(data) In [5]: df["categorical"] = df["object"].astype("category") In [6]: df.info() <class 'pandas.DataFrame'> RangeIndex: 5000 entries, 0 to 4999 Data columns (total 8 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 int64 5000 non-null int64 1 float64 5000 non-null float64 2 datetime64[ns] 5000 no
๐ŸŒ
Medium
medium.com โ€บ @i-jesse โ€บ exploring-data-frames-f10218a5d3bd
Exploring Data Frames. shape, head, tail, info, describe, | by I. Jesse | Medium
March 23, 2025 - df.info() The outputwill have something like ยท <class 'pandas.core.frame.DataFrame'> RangeIndex: 8 entries, 0 to 7 Data columns (total 2 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 column_1 8 non-null float64 1 column_2 8 non-null float64 ยท
๐ŸŒ
Bodo
docs.bodo.ai โ€บ 2026.2 โ€บ api_docs โ€บ pandas โ€บ dataframe โ€บ info
pd.DataFrame.info - Bodo Developer Documentation
pandas.DataFrame.info(verbose=None, buf=None, max_cols=None, memory_usage=None, show_counts=None, null_counts=None) >>> @bodo.jit ... def f(): ... df = pd.DataFrame({"A": [1,2,3], "B": ["X", "Y", "Z"], "C": [pd.Timedelta(10, unit="D"), pd.Timedelta(10, unit="H"), pd.Timedelta(10, unit="S")]}) ...
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.DataFrame.memory_usage.html
pandas.DataFrame.memory_usage โ€” pandas 3.0.2 documentation
This value is displayed in DataFrame.info by default. This can be suppressed by setting pandas.options.display.memory_usage to False.
๐ŸŒ
LabEx
labex.io โ€บ tutorials โ€บ pandas-dataframe-info-method-68636
Pandas DataFrame Info Method | LabEx
df.info() After running the code, you will see the summary information about the DataFrame, including the data type of each column, the number of non-null values, and the memory usage.
๐ŸŒ
Readthedocs
eland.readthedocs.io โ€บ en โ€บ v8.13.1 โ€บ reference โ€บ api โ€บ eland.DataFrame.info.html
eland.DataFrame.info - eland 8.13.1 documentation
This method prints information about a DataFrame including the index dtype and column dtypes, non-null values and memory usage. See pandas.DataFrame.info for full details.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ call to dataframe.info() causes huge memory consumption. why?
r/learnpython on Reddit: Call to DataFrame.info() causes huge memory consumption. Why?
February 25, 2022 -

Hello experts,

I was happily hacking around with a csv file containing logs which I want to analyse in pandas, when I noticed something funny about the memory consumption: while the RAM consumption of the loaded dataframe roughly matches the size of the csv file (โ‰ˆ3.1GB), a call to DataFrame.info() shoots up the system's memory usage by another few GB. Looking at htop, the call to DataFrame.info() quickly consumes another 2.5 GB of free RAM.

Here's a self-contained script (minus the data, which I can provide should there be more mystery to this than expected) and it's stdout.

import pandas as pd
import psutil

df = pd.read_csv("./logs-unique.tsv", sep="\t")

# Convert the timestamps to their proper datetime equivalent. We truncate the
# input dates at the 1s-resolution.
def convert_time(series):
    datetime_series = series.str.extract(r"(^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}\.[0-9]{2}\.[0-9]{2})")[0]
    return pd.to_datetime(datetime_series, format="%Y-%m-%dT%H.%M.%S")
df["Time"] = convert_time(df["Time"])

# Convert the following categories to a proper category type. Note that by
# default, the pandas category type is unordered and its categories are inferred
# from the data. Hence the simple .astype("category") will do just fine.
df["Category"] = df["Category"].astype("category")
df["User"] = df["User"].astype("category")
df["Tenant"] = df["Tenant"].astype("category")
df["Account"] = df["Account"].astype("category")
df["Application"] = df["Application"].astype("category")
df["Message"] = df["Message"].astype("category")

# Drop the 'InstanceId' column, as its completely empty as well as the
# 'FormatVersion' column, whose values are all '2.2'.
df.drop(columns=["InstanceId", "FormatVersion"], inplace=True)

print(f"Free RAM before call to 'info()': {psutil.virtual_memory().available / 1e9} GB", end="\n\n")
print(df.info(memory_usage="deep"), end="\n\n")
print(f"Free RAM after call to 'info()' : {psutil.virtual_memory().available / 1e9} GB")
Free RAM before call to 'info()': 5.57312 GB

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 2884211 entries, 0 to 2884210
Data columns (total 9 columns):
 #   Column       Dtype         
---  ------       -----         
 0   Uuid         object        
 1   Category     category      
 2   User         category      
 3   Tenant       category      
 4   Account      category      
 5   Application  category      
 6   Time         datetime64[ns]
 7   Message      category      
 8   Duplicity    int64         
dtypes: category(6), datetime64[ns](1), int64(1), object(1)
memory usage: 3.0 GB
None

Free RAM after call to 'info()' : 3.046608896 GB

Notice how 2.5 GB of free RAM seem to vanish. This happens everytime, inside and outside of my jupyter notebook. Also, the rather similar command DataFrame.memory_usage() does not swallow any memory.

May I kindly ask you to help me find out what's going on here?

Thanks

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ pandas โ€บ introduction-to-pandas-in-python
Pandas Introduction - GeeksforGeeks
Pandas provides essential operations for working with structured data efficiently. The sections below introduce the most commonly used functionalities with short explanations and simple examples. 1. Loading Data: This operation reads data from files such as CSV, Excel or JSON into a DataFrame. ... Explanation: pd.read_csv("data.csv") reads the CSV file and loads it into a DataFrame and df.head() shows the first 5 rows of the data.
Published ย  January 13, 2026
๐ŸŒ
Saturn Cloud
saturncloud.io โ€บ blog โ€บ how-to-show-all-column-names-on-a-large-pandas-dataframe
How to Show All Column Names on a Large Pandas DataFrame | Saturn Cloud Blog
January 9, 2024 - To use this method, you can call the DataFrame.info() method on your dataframe, as shown below: import pandas as pd df = pd.read_csv('large_dataframe.csv') df.info()