[Python] pandas set_option('display.max_columns', None) is working for me

Discussão em 'Python' iniciado por Stack, Junho 20, 2025.

  1. Stack

    Stack Membro Participativo

    entering pandas set_option('display.max_columns,None) causes the python print function to print just some of the columns, then - below that, come back and print the rest of the columns.

    I downloaded https://media.geeksforgeeks.org/wp-content/uploads/nba.csv and loaded it to a dataframe and printed it (as below)

    import pandas as pd

    pd.set_option('display.max_columns', None)

    data = pd.read_csv(r"D:\DriveD\Study\Python\Files\nba.csv", index_col ="Name")
    print()
    print(data)
    print()


    It prints the 'Name' column and the next 6 columns, then under those 10 rows it prints the 'Name' columns again, along with the corresponding last two columns, for those same 10 rows.

    I can redo the 'set_option' entry as below:

    panda.set_option('display.max_rows', None,'display.max_colwidth', None)


    and it prints the 'Name' along with the other 8 columns on one line, for all 457 rows.

    SO - if I don't do the pd.setoption('display.max_columns,None) then it prints AS EXPECTED, i.e. each row is printed on one line.

    I'm using VS Code, python version 3.13.3. Windows 10.

    Continue reading...

Compartilhe esta Página