I would like to display the output pandas.DataFrame.info()in a text widget tkinter, so I need a string. However, pandas.DataFrame.info()returns NoneType, anyway, can I change this?
import pandas as pd
import numpy as np
data = np.random.rand(10).reshape(5,2)
cols = 'a', 'b'
df = pd.DataFrame(data, columns=cols)
df_info = df.info()
print(df_info)
type(df_info)
I would like to do something like:
info_str = ""
df_info = df.info(buf=info_str)
Is it possible to get pandasto return a string object from DataFrame.info()?
source
share