删除csv, python中的索引号
如何删除索引号,并用eTime值代替。
import numpy as np
import pandas as pd
# load data from csv
data = pd.read_csv('log_level_out_mini.csv', delimiter=';')
time = data['eTime']
angka = data['eValue']
# Calculating cross-sectional area
diameter = 0.1016 # 4 Inch
A = 1/4 * np.pi * diameter ** 2
print('Luas penampang:', A)
# Calculate Flow Rate
Q = angka * A
print('Flow Rate:', Q)
# Calculate Volume
结果如下。
Time eValue
0 2017-07-16 00:00:50.017 -0.272
1 2017-07-16 00:01:50.017 -0.272
2 2017-07-16 00:02:50.020 -0.272
3 2017-07-16 00:03:50.003 -0.272
4 2017-07-16 00:04:50.020 -0.272
... ... ...
10032 2017-07-22 23:55:23.803 0.588
10033 2017-07-22 23:56:23.793 0.580
10034 2017-07-22 23:57:23.787 0.583
10035 2017-07-22 23:58:23.797 0.569
10036 2017-07-22 23:59:23.800 0.549
如何删除列表索引并更改为eTime值?
设置index_col
等于False
,按照这里列出的文档:
注意:index_col=False可用于强制pandas不使用第一列作为索引,例如,当您有一个格式错误的文件,每行末尾都有分隔符时。
所以改变:
data = pd.read_csv('log_level_out_mini.csv', delimiter=';')
:
data = pd.read_csv('log_level_out_mini.csv', delimiter=';', index_col=False)