LincolnJ
LincolnJ

Reputation: 71

Python Pandas: dtypes not show column types for all columns

I have a csv data file with 101 columns and I would like to see the type for each column. I use

dat=pandas.read_csv("try.csv")
dat.dtypes

It returns only first and last 15 columns with types. All other columns are truncated. And there is ... in between

I wonder how can I see types for all columns? Thanks a lot!

Upvotes: 6

Views: 8351

Answers (3)

Mahesh Babu J
Mahesh Babu J

Reputation: 151

I think this is better way when in Jupyter notebook,

from IPython.display import HTML
HTML(pd.DataFrame(dat.dtypes).to_html()

Upvotes: 0

Andrea Araldo
Andrea Araldo

Reputation: 1442

I think a good way is this

dat.info(verbose=True)

as suggested in this post.

I think it is better than the solution of EdChum since it does not force you to change the default display setting

Upvotes: 2

EdChum
EdChum

Reputation: 393933

You are seeing a truncated output because pandas is protecting you from printing reams of information in the output. You can override this:

pd.set_option('display.max_rows', 120)

The default setting is 60

A list can be found here: http://pandas.pydata.org/pandas-docs/stable/options.html

and also related: List of pandas options for method set_option

Upvotes: 8

Related Questions