如何修复向axis提供多个轴已不再受支持的错误

2024-04-26 01:16:15 发布

您现在位置:Python中文网/ 问答频道 /正文

import pandas as pd
import numpy as np
import sklearn
from sklearn import preprocessing, neighbors, svm
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt

df = pd.read_csv(r'C:\Users\Home\Desktop\result-messidor.csv')
df.replace('?', -99999, inplace=True)
df.dropna(['id'], 1, inplace=True)
x = np.array(df.dropna(['class'], 1, axis=1))
y = np.array(df['class'])
x_train, x_test, y_train, y_test = sklearn.model_selection.train_test_split(x, y, test_size=0.2)
clf = svm.SVC(kernel='linear')
clf.fit(x_train, y_train)
acc = clf.score(x_test, y_test)
print(acc)

我正在尝试使用SVM算法确定精度 但我有这个错误

Traceback (most recent call last):
  File "C:/Users/Home/PycharmProjects/rrrr/Arwa1.py", line 10, in <module>
    df.dropna(['id'], 1, inplace=True)
  File "C:\Users\Home\Desktop\enviroment\lib\site-packages\pandas\core\frame.py", line 4734, in dropna
    raise TypeError("supplying multiple axes to axis is no longer supported.")
TypeError: supplying multiple axes to axis is no longer supported.

我怎样才能解决这个问题


Tags: testimporttruepandasdfhomeasnp