Python output "News Headline" not completely displayed

Hello dear community,

I would like to generate a dataset that captures the news about a stock in a period of time.

However, under the code described in the photo is not displayed in full, but with ... for two columns shortened. I am using PyCharm.

Can someone help me in this case?

Thanks a lot already!

With kind regards

Lukas Rohde

bildschirmfoto-2022-07-07-um-092603.png

Best Answer

  • wasin.w
    wasin.w admin
    Answer ✓

    Hello @infojw

    By default, the Pandas also displays only a limited number of columns.

    However, you can use the Pandas option_context() method to set a temporary number of columns:

    Example:

    import pandas as pd
    ...
    # Request data
    with pd.option_context('display.max_columns', None):
        print(newsheadlines)

    Result:

    full-width-1.png

    Note: Since you are printing the Pandas dataframe in a console, so there are some limitations on displaying long data. The dataframe is designed to be displayed on the IPython environment such as Jupyter Noteboook/Julyterlab, not a console.

    Hope this helps.

Answers