This is likely very simple but I can’t figure out what’s wrong.
I am having trouble listing elements of a DataFrame. Sometimes the elements of a DataFrame are listed and sometimes it’s simply a description of the number and types of the data columns.
I know that the number of rows is a factor but even when I have only a few rows, I only get the description back.
For example:
If I have a DataFrame called ‘allpledges’, it gives me a description
In [5]:
allpledges
Out[5]:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 305384 entries, 0 to 305383
Data columns:
Pledge# 305384 non-null values
Source 305384 non-null values
Date 305384 non-null values
Break 305384 non-null values
Progcode 237002 non-null values
Which is understandable because it’s too many rows to display.
But when I try to view a few, it still gives me the same thing
In [13]:
allpledges[:5]
Out[13]:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 5 entries, 0 to 4
Data columns:
Pledge# 5 non-null values
Source 5 non-null values
Date 5 non-null values
Break 5 non-null values
Progcode 0 non-null values
When what I wanted was the top five rows listed out. I have seen this done in tutorials, but can’t figure out what I am doing wrong here.
These settings are controlled in the
options(I suspect you’re looking formax_rowsormax_columns, but there are many options seen in theset_optionsdocstring):And change them using
set_option:If the DataFrame either has more columns or more rows than these settings it will abbreviate.
For example: