I am not able to read my dataset.csv file due to following Parser Error.
Error tokenizing data. C error: Expected 1 fields in line 8, saw 4
The CSV file is generated through another program. Basically I want to skip the character rows which are iterating after certain intervals and want only the integer and float values in my dataset. I tried this:
df = pd.read_csv('Dataset.csv')
Run Code Online (Sandbox Code Playgroud)
I also tried this, but i am only getting the bad lines as output. …
我想将具有整数的 2 列值与它们之间的“_”组合起来,并将其设置为我的输出数据集的索引列。“ID”将是我的索引。
样本数据:
import pandas as pd
import numpy as np
import io
data = '''
ID,Ang,1
23,0,0.88905321
23,10,0.962773412
23,20,1.004187813
23,30,1.008301223
105,0,0.334209544
105,10,0.39043363
105,20,0.434241204
105,30,0.460348427
47,0,0.020669404
47,10,0.032299446
47,20,0.050602654
47,30,0.073371391
'''
df = pd.read_csv(io.StringIO(data),index_col=0)
Run Code Online (Sandbox Code Playgroud)
预期输出:
假设
A='First'
B='Random'
C='Degree'
D='Largest'
A='Second'
B='Odd'
C='Inclined'
D='Maximum'
print('Group '+ A)
print('Number '+ B)
print('Angle '+ C)
print('Max value ' + D)
Run Code Online (Sandbox Code Playgroud)
我的实际输出是这种形式,
Group Second
Number Odd
Angle Inclined
Max Value Maximum
Run Code Online (Sandbox Code Playgroud)
预期输出:我想将这些索引安排为列标签,并将输出存储在csv文件中,如下所示:
像这样,如果有'N'值,csv文件应将所有值存储在另一个值之下