To get basic information about a DataFrame including the column names and datatypes:
import pandas as pd
df = pd.DataFrame({'integers': [1, 2, 3],
'floats': [1.5, 2.5, 3],
'text': ['a', 'b', 'c'],
'ints with None': [1, None, 3]})
df.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 3 entries, 0 to 2
Data columns (total 4 columns):
floats 3 non-null float64
integers 3 non-null int64
ints with None 2 non-null float64
text 3 non-null object
dtypes: float64(2), int64(1), object(1)
memory usage: 120.0+ bytes
To get the memory usage of the DataFrame:
>>> df.info(memory_usage='deep')
<class 'pandas.core.frame.DataFrame'>
Int64Index: 3 entries, 0 to 2
Data columns (total 4 columns):
floats 3 non-null float64
integers 3 non-null int64
ints with None 2 non-null float64
text 3 non-null object
dtypes: float64(2), int64(1), object(1)
memory usage: 234.0 bytes