DataMan
DataMan

Reputation: 3455

Jupyter Notebook: Print Pandas Dataframe without wrapping on a new line (print statement is in external function)

I have a function from a package imported into my Jupyter Notebook. Inside of the function is a print statement that prints a Pandas Dataframe. Let's say I can't (or don't want to) change the code of the function I'm importing. Is there a way to have the Pandas Dataframe being printed to not wrap over in the Jupyter output cell? I.e. how do I make it print on a single line such that I can scroll left to right?

I know about using Jupyter's display function instead of print, but the problem is that the print statement is in the package I'm importing and I can't change the package code.

Upvotes: 5

Views: 3421

Answers (1)

B. John845
B. John845

Reputation: 61

I believe you can use the set option function inside of Pandas options. I'm not 100% sure this is what you were looking for but this sounds like what you would want to do.

import pandas as pd
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)

Then when you display the code you will see your scroll bar at the bottom of the notebook to go left and right to see the full print statement.

Upvotes: 6

Related Questions