Pandas 数据帧去除非数字字符

我正在处理以下形式的数据:


Accuracy 26.15%, error rate 0.00%, not classified 73.85%

Accuracy 29.68%, error rate 0.00%, not classified 70.32%

Accuracy 33.98%, error rate 0.00%, not classified 66.02%

Accuracy 35.34%, error rate 0.00%, not classified 64.66%

Accuracy 35.75%, error rate 0.00%, not classified 64.25%

Accuracy 37.51%, error rate 0.00%, not classified 62.49%

Accuracy 38.63%, error rate 0.00%, not classified 61.37%

Accuracy 40.81%, error rate 0.00%, not classified 59.19%

Accuracy 41.22%, error rate 0.00%, not classified 58.78%

Accuracy 41.99%, error rate 0.00%, not classified 58.01%

Accuracy 42.34%, error rate 0.00%, not classified 57.66%

Accuracy 42.40%, error rate 0.00%, not classified 57.60%

Accuracy 43.05%, error rate 0.00%, not classified 56.95%

Accuracy 44.29%, error rate 0.00%, not classified 55.71%

Accuracy 44.35%, error rate 0.00%, not classified 55.65%

Accuracy 44.76%, error rate 0.00%, not classified 55.24%

Accuracy 45.29%, error rate 0.00%, not classified 54.71%

Accuracy 45.35%, error rate 0.00%, not classified 54.65%

Accuracy 95.35%, error rate 4.24%, not classified 0.41%

Accuracy 95.76%, error rate 4.24%, not classified 0.00%

Stats on test data

Accuracy 94.74%, error rate 5.26%, not classified 0.00%

如何将其加载到 Pandas 数据框中,标题为“准确性”、“错误率”和“未分类”,同时还从数据字段中删除非数字字符。


到目前为止,我有:


pd.read_csv("test.csv", names=['Accuracy', 'Error rate', 'Not classified'])

但这会产生:


    Accuracy    Error rate  Not classified

0   Accuracy 25.85% error rate 0.00%    not classified 74.15%

1   Accuracy 29.92% error rate 0.00%    not classified 70.08%

2   Accuracy 33.69% error rate 0.00%    not classified 66.31%

3   Accuracy 36.16% error rate 0.00%    not classified 63.84%

4   Accuracy 37.16% error rate 0.00%    not classified 62.84%

5   Accuracy 39.28% error rate 0.00%    not classified 60.72%

6   Accuracy 39.58% error rate 0.00%    not classified 60.42%

7   Accuracy 40.05% error rate 0.00%    not classified 59.95%


噜噜哒
浏览 264回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python