Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display all information with data.info() in Pandas

Tags:

python

pandas

I would display all information of my data frame which contains more than 100 columns with .info() from pandas but it won't :

data_train.info()

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 85529 entries, 0 to 85528
Columns: 110 entries, ID to TARGET
dtypes: float64(40), int64(19), object(51)
memory usage: 71.8+ MB

I would like it displays like this :

data_train.info()

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 10886 entries, 0 to 10885
Data columns (total 12 columns):
datetime      10886 non-null object
season        10886 non-null int64
holiday       10886 non-null int64
workingday    10886 non-null int64
weather       10886 non-null int64
temp          10886 non-null float64
atemp         10886 non-null float64
humidity      10886 non-null int64
windspeed     10886 non-null float64
casual        10886 non-null int64
registered    10886 non-null int64
count         10886 non-null int64
dtypes: float64(3), int64(8), object(1)
memory usage: 1020.6+ KB

But the problem seems to be the high number of columns from my previous data frame. I would like to show all values including non null values (NaN).

like image 202
brad_curtis Avatar asked Apr 15 '17 15:04

brad_curtis


People also ask

What does info () do in Python?

The info() method prints information about the DataFrame. The information contains the number of columns, column labels, column data types, memory usage, range index, and the number of cells in each column (non-null values). Note: the info() method actually prints the info.

How can I see full data in pandas?

Use pandas.max_rows", max_rows, "display. max_columns", max_cols) with both max_rows and max_cols as None to set the maximum number of rows and columns to display to unlimited, allowing the full DataFrame to be displayed when printed.

Which command gives the information summary of the data?

DataFrame - info() function. The info() function is used to print a concise summary of a DataFrame. This method prints information about a DataFrame including the index dtype and column dtypes, non-null values and memory usage.


1 Answers

You can pass optional arguments verbose=True and show_counts=True (null_counts=True deprecated since pandas 1.2.0) to the .info() method to output information for all of the columns

pandas >=1.2.0: data_train.info(verbose=True, show_counts=True)

pandas <1.2.0: data_train.info(verbose=True, null_counts=True)

like image 93
James Avatar answered Sep 22 '22 16:09

James