Pandas Error df.head ()

I am having a major problem with df.head (). When a function is executed, it usually displays an HTML table with the top 5 values, but now it appears only for a piece of data and outputs, as shown below:

<class 'pandas.core.frame.DataFrame'> Int64Index: 5 entries, 0 to 4 Data columns (total 9 columns): survived 5 non-null values pclass 5 non-null values name 5 non-null values sex 5 non-null values age 5 non-null values sibsp 5 non-null values parch 5 non-null values fare 5 non-null values embarked 5 non-null values dtypes: float64(2), int64(4), object(3) 

Looking at this thread , I tried

 pd.util.terminal.get_terminal_size() 

and got the expected result (80, 25). Manual print settings using

 pd.set_printoptions(max_columns=10) 

Produces the same chopped data results as above.

This was confirmed after diving into the documentation here and using

 get_option("display.max_rows") get_option("display.max_columns") 

and get the correct default values ​​from 60 rows and 10 columns.

I have never had a problem with df.head (), but now this is a problem in all of my IPython Notebooks.

I am running pandas 0.11.0 and IPython 0.13.2 in Google Chrome.

+4
source share
2 answers

In pandas 11.0, I think the minimum is display.height and max_rows (and display.width and max_columns`), so you need to manually change this too.

I don't like this, I posted this github issue about this earlier.

+4
source

Try the following to display the top 10 items.

 from IPython.display import HTML HTML(users.head(10).to_html()) 

I think the pandas 11.0 head function is completely intuitive and should just stay like head () and you will get your html.

+2
source

Source: https://habr.com/ru/post/1481779/


All Articles