小编Ash*_* E.的帖子

无法在 VS Code 中导入

I'm new to python and I've been using VS code. Right now I'm working on a Thompson Sampling problem that requires numpy and matplotlib. I've imported both libraries but VS code is giving the error unable to import. I know I have to install with PIP, and I have seen other solutions about changing the Python path through the json. but I'm afraid to do that because I don't want to mess up my text editor. Can someone walk me …

python pip visual-studio python-3.x

5
推荐指数
1
解决办法
1万
查看次数

关键错误:[Int64Index ...] dtype ='int64]都不在列中

我正在尝试使用np.random.shuffle()方法调整索引,但是我不断收到我不理解的错误。如果有人可以帮助我解决这个问题,我将不胜感激。谢谢!

我一开始就将raw_csv_data变量设为变量时,曾尝试使用delimiter =','和delim_whitespace = 0,因为我将其视为另一个问题的解决方案,但它始终抛出相同的错误

    import pandas as pd 
    import numpy as np 
    from sklearn.preprocessing import StandardScaler

    #%%
    raw_csv_data= pd.read_csv('Absenteeism-data.csv')
    print(raw_csv_data)
    #%%
    df= raw_csv_data.copy()
    print(display(df))
    #%%
    pd.options.display.max_columns=None
    pd.options.display.max_rows=None
    print(display(df))
    #%%
    print(df.info())
    #%%
    df=df.drop(['ID'], axis=1)

    #%%
    print(display(df.head()))

    #%%
    #Our goal is to see who is more likely to be absent. Let's define
    #our targets from our dependent variable, Absenteeism Time in Hours
    print(df['Absenteeism Time in Hours'])
    print(df['Absenteeism Time in Hours'].median())
    #%%
    targets= np.where(df['Absenteeism Time in Hours']>df['Absenteeism Time 
    in Hours'].median(),1,0)
    #%%
    print(targets) …
Run Code Online (Sandbox Code Playgroud)

python numpy pandas scikit-learn

5
推荐指数
2
解决办法
8880
查看次数

标签 统计

python ×2

numpy ×1

pandas ×1

pip ×1

python-3.x ×1

scikit-learn ×1

visual-studio ×1