ParserError:错误标记数据。 C 错误:第 27 行需要 1 个字段,看到 367

问题描述 投票:0回答:1

plz...我累了,帮我弄清楚

这是我的代码

import pandas as pd
url="https://github.com/selva86/datasets/blob/master/Ionosphere.csv"
df=pd.read_csv(url)
df.head()

ParserError:错误标记数据。 C 错误:第 27 行需要 1 个字段,看到 367

python pandas
1个回答
1
投票

您需要convert您的

URL
,以便它包含
raw.githubusercontent.com
域。
raw.githubusercontent.com
域用于提供存储在 GitHub 存储库中的文件的未处理版本。如果您浏览到 GitHub 上的一个文件,然后单击 Raw 链接,那么您就会去那里。这就是您的代码中的样子:

import pandas as pd
url="https://raw.githubusercontent.com/selva86/datasets/master/Ionosphere.csv"
df=pd.read_csv(url)

df.head()
回报:

   V1  V2       V3       V4       V5       V6       V7       V8       V9      V10      V11      V12  ...      V24      V25      V26      V27      V28      V29      V30      V31      V32      V33      V34  Class
0   1   0  0.99539 -0.05889  0.85243  0.02306  0.83398 -0.37708  1.00000  0.03760  0.85243 -0.17755  ... -0.47357  0.56811 -0.51171  0.41078 -0.46168  0.21266 -0.34090  0.42267 -0.54487  0.18641 -0.45300      1
1   1   0  1.00000 -0.18829  0.93035 -0.36156 -0.10868 -0.93597  1.00000 -0.04549  0.50874 -0.67743  ... -0.35734 -0.20332 -0.26569 -0.20468 -0.18401 -0.19040 -0.11593 -0.16626 -0.06288 -0.13738 -0.02447      0
2   1   0  1.00000 -0.03365  1.00000  0.00485  1.00000 -0.12062  0.88965  0.01198  0.73082  0.05346  ... -0.12062  0.57528 -0.40220  0.58984 -0.22145  0.43100 -0.17365  0.60436 -0.24180  0.56045 -0.38238      1
3   1   0  1.00000 -0.45161  1.00000  1.00000  0.71216 -1.00000  0.00000  0.00000  0.00000  0.00000  ...  0.00000  1.00000  0.90695  0.51613  1.00000  1.00000 -0.20099  0.25682  1.00000 -0.32382  1.00000      0
4   1   0  1.00000 -0.02401  0.94140  0.06531  0.92106 -0.23255  0.77152 -0.16399  0.52798 -0.20275  ... -0.52879  0.03286 -0.65158  0.13290 -0.53206  0.02431 -0.62197 -0.05707 -0.59573 -0.04608 -0.65697      1

[5 rows x 35 columns]
© www.soinside.com 2019 - 2024. All rights reserved.