Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printing panda dataframe mislabels columns #2250

Closed
wyy1997 opened this issue Feb 23, 2020 · 6 comments
Closed

Printing panda dataframe mislabels columns #2250

wyy1997 opened this issue Feb 23, 2020 · 6 comments
Assignees

Comments

@wyy1997
Copy link

wyy1997 commented Feb 23, 2020

Issue Type: Bug

Create a two-dimensional array using Python: Pandas: DataFrame, and output a table column index top that does not correspond to the data
import pandas as pd from pandas import Series, dict2 = {'a':[1, 2, 3], 'b':[4, 5, 6]} df6 = pd.DataFrame.from_dict(dict2) print(df6)

browser_run
vscoderun

Extension version: 2020.3.63821-dev
VS Code version: Code 1.42.1 (c47d83b293181d9be64f27ff093689e8e7aed054, 2020-02-11T14:45:59.656Z)
OS version: Windows_NT x64 10.0.18362

System Info
Item Value
CPUs Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz (4 x 2304)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off
surface_control: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 7.88GB (1.88GB free)
Process Argv
Screen Reader no
VM 40%
@karthiknadig karthiknadig changed the title 朱皮特的输出有错误 朱皮特的输出有错误 (translated: Jupiter's output has errors) Feb 24, 2020
@rchiodo
Copy link
Contributor

rchiodo commented Feb 24, 2020

This has to do with the styles in the output of print(df6). You can work around this by using df.head() instead or by using the data viewer in the Variables:

image

@greazer greazer changed the title 朱皮特的输出有错误 (translated: Jupiter's output has errors) Printing panda dataframe mislabels columns Feb 24, 2020
@RMeli
Copy link

RMeli commented Mar 30, 2020

I have the same problem.


df = pd.DataFrame(np.arange(9).reshape(3,3), index=list("abc"), columns=list("def"))

Output with Jupyter Notebook or IPython console (expected, correct):

   d  e
a  0  1
b  3  4
c  6  7

Output with VSCode:

d  e
a  0  1
b  3  4
c  6  7

VSCode: 1.43.2
Python for VSCode: 2020.3.69010

pandas: 1.0.3

jupyter core : 4.6.3
jupyter-notebook : 6.0.3
qtconsole : 4.7.2
ipython : 7.13.0
ipykernel : 5.2.0
jupyter client : 6.1.2
jupyter lab : not installed
nbconvert : 5.6.1
ipywidgets : 7.5.1
nbformat : 5.0.4
traitlets : 4.3.3

@RMeli
Copy link

RMeli commented Mar 30, 2020

Printing the DataFrame a second time does not show the same issue:

df = pd.DataFrame(np.arange(9).reshape(3,3), index=list("abc"), columns=list("def"))

print(df, "\n")
print(df)
d  e  f
a  0  1  2
b  3  4  5
c  6  7  8 

   d  e  f
a  0  1  2
b  3  4  5
c  6  7  8

Is the output of the cell stripped of beginning/end withe spaces?

@whlinaa
Copy link

whlinaa commented Aug 3, 2020

This is actually a bug of VS Code, which automatically remove the leading whitespaces of a print() statement.

Example: write print(" hello world"), and the output will remove the leading whitespaces of this statement.

VS Code, please help resolve this problem. This is really driving Python users nuts.

More info: microsoft/vscode#103766

@rchiodo
Copy link
Contributor

rchiodo commented Aug 5, 2020

Moving back to triage. We've been getting a bunch of dupes of this.

Note: One of the dupes was marked as Nice To Have for July.

@rchiodo
Copy link
Contributor

rchiodo commented Aug 10, 2020

Validated. Should be in September release.

@rchiodo rchiodo closed this as completed Aug 10, 2020
@DonJayamanne DonJayamanne transferred this issue from microsoft/vscode-python Nov 13, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants