skip to Main Content

enter image description here

I do not like the presentation format that separates my dataframe into two rows. This problem also appears in my debug console, but it was not like that some days ago. I clicked the "…" on the left of the output and select "change presentation", but VSCode only gives me one option ( shown in the last image). It had about three options before, but they are not here anymore.

I followed this answer to change my settings.json, but it makes no difference. What can I do to have all the columns display in one row?

enter image description here

My settings.json is

{
"workbench.colorTheme": "Default Dark+",
"[python]": {
    "editor.formatOnType": true
},
"git.autofetch": true,
"notebook.displayOrder": [
    "image/png",
    "text/plain"
 ]
}

2

Answers


  1. An existing problem on github. The output will be unreadable if working with wide dataframes.

    One feasible approach is to use the data viewer by clicking Variables.

    enter image description here

    enter image description here

    Then you could get the table as an alternative. I’ve submitted your original problem as a feature request to developer on github.

    Login or Signup to reply.
  2. Instead of using:

    print(df.head())
    

    just use:

    df.head()
    

    It will print your csv in a prettier format without dataframe separation, but make sure that variable is at the end of the code.

    import pandas as pd
    
    df = pd.read_csv('homelessness.csv')
    df['x'] = '541651348'
    df.head()
    

    If the dataframe is in collapse mode, you can expand/show all columns with this pandas setup:

    pd.set_option('display.max_columns', None)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search