UCSD-PL / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
0 stars 7 forks source link

concactenating string to int shows `rv=None` instead of type error in PB #52

Closed rlisahuang closed 1 year ago

rlisahuang commented 1 year ago

To replicate:

import matplotlib.pyplot as plt
import pandas as pd
import io

csv = '''
ID,group,time,success
P1,control,18.6,1
P2,control,15.42,1
P3,control,25.55,0
P4,control,12.56,0
P5,control,8.67,1
P6,experiment,7.31,0
P7,experiment,9.66,0
P8,experiment,13.64,1
P9,experiment,14.92,1
P10,experiment,18.47,1
'''

df = pd.read_csv(io.StringIO(csv))

# create a box plot where each box refers to a group
df.boxplot(column='time', by='group')

# remove the grid and increase the limit of y axis to 30
plt.grid(False)
plt.ylim(0, 30)

# add a dashed horizontal line at y=25
plt.axhline(y=25, linestyle='--')

# add a label "limit" next to the horizontal line
plt.text(x=2.45, y=25.5, s='limit')

# for each group, add scatter dots on top of the box using the time data, and mark the dots with blue if success=1, otherwise red
for i, group in df.groupby('group'):
    scatter_x = [i + 1] * len (group ['success'])
    colors = ['blue' if x else 'red' for x in group ['success']]
    plt.scatter(scatter_x, group['time'], marker='o', color=colors)

The stderr does show up in the output panel. However, in PB, it shows:

Screenshot 2023-03-13 at 10 13 28 PM

Could be replicated both locally and on the web version.

KasraF commented 1 year ago

I was able to replicate it with this minimal example:

import pandas as pd

df = pd.DataFrame(['x'],None,['y'])
for i, group in df.groupby('y'):
    z = i + 1

I couldn't replicate it if I replaced df.groupby with a local function or method call though, so it seems to be related to pandas, or at least to calling methods in a different module?

KasraF commented 1 year ago

See d379b04d14f788607b2f5f22cf7df262abd43e47 for fix.