Python - Getting wider output in PyCharm's built-in console

Learn, how can we get wider output in PyCharm's built-in console?
Submitted by Pranit Sharma, on August 10, 2022

Pandas is a special tool that allows us to perform complex manipulations of data effectively and efficiently. Inside pandas, we mostly deal with a dataset in the form of DataFrame. DataFrames are 2-dimensional data structures in pandas. DataFrames consist of rows, columns, and data.

What is PyCharm?

Pycharm is another python based Integrated Development Environment, which provides multiple tools and features to python developers which are helpful in designing games, and web applications and of course play an important role in data analytics.

Wider output issue in PyCharm's built-in console

In Pycharm, the default printing method does not print the entire columns. It compresses the rows and columns. In this article, we are going to learn how to expand the output display to see all the columns of DataFrame?

Getting wider output in PyCharm's built-in console

We can widen the output display with the help of the pandas.df.setoptions() method allows us to set different properties according to our requirements. The display.max_columns() defines the total number of columns to be printed. If None is passed as an argument, all columns would be printed.

Let us understand with the help of an example,

Program with wider output issue in PyCharm

# Importing pandas package
import pandas as pd

# Importing numpy package
import numpy as np

# Creating a Dictionary with 25 keys
d = {}
for i in range(1,25):
    d[i]=[i for i in range(1,10)]

# Creating a DataFrame
df = pd.DataFrame(d)

# Display original DataFrames
print("Original DataFrame :\n",df,"\n")


The output of the above program is:

Example 1: Wider output in PyCharm's

Program to solve wider output issue in PyCharm

As the output shows, there are a total of 24 columns, but only 15 are visible, to overcome this, we will use the pandas.df.setoptions() method.

# Setting value of columns=20
pd.set_option('display.max_columns', 24)

# Viewing modified DataFrame
print("Modified DataFrame:\n",df)


The output of the above program is:

Example 2: Wider output in PyCharm's

Python Pandas Programs »

Comments and Discussions!

Load comments ↻

Copyright © 2024 All rights reserved.