Skip to main content
pandas DataFrame printing

How do you deal with pandas DataFrames not printing in full?

Richie Cotton avatar
Written by Richie Cotton
Updated over 5 years ago

Question:

Why don't the pandas DataFrames print properly in the DataCamp console? I only see one or two columns printed.

Answer:

pandas v0.23 introduced a "smart" printing system that guesses the width of the console in order to print a suitable number of columns.

This feature does not work correctly on the DataCamp platform, meaning that pandas thinks the console has a width of zero characters, causing it to display minimum amount allowed by the print method.

To fix this add the following lines to the end of the requirements.sh  file.

cat <<EOT >> $PYTHONSTARTUP                     
import pandas as pd                     pd.set_option('display.max_columns', 10)             pd.set_option('display.width', 200)                 EOT 

Did this answer your question?