1.删除csv首行(属性)
d = open('filtered_data.csv').readlines() d[0] = ''with open('new_filtered_data.csv', 'w') as f: f.writelines(d)
2.删除csv第一列(序号)
import csv d_new=open('new_filtered_data.csv','r') df=csv.reader(d_new) data = []for row in df: data.append(row[1:])
3.读取csv为list
import csv d_new=open('new_filtered_data.csv','r') df=csv.reader(d_new)data=list(df)
4.读取csv为DataFrame
f = open('filtered_data.csv', encoding='GBK') df = pd.read_csv(f) data = pd.DataFrame(df.iloc[:, 1:].values)