1

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"
 ]
}
3
  • stackoverflow.com/a/58665752/53341 Commented Mar 21, 2023 at 6:39
  • @MatBailie print(dataframe.to_string()) might be better. Commented Mar 21, 2023 at 6:46
  • This answer should be better too. :) Commented Mar 21, 2023 at 6:48

2 Answers 2

1

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)
Sign up to request clarification or add additional context in comments.

Comments

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.

1 Comment

Thank you for submitting my question to the developer. I appreciate it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.