Remove index number in csv, python
how to remove index number, and replace it with eTime value.
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
this is the result.
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
how to remove a list index and change to eTime Value?
CodePudding user response:
Set index_col
equal to False
, as per the documentation listed here:
Note: index_col=False can be used to force pandas to not use the first column as the index, e.g. when you have a malformed file with delimiters at the end of each line.
So change:
data = pd.read_csv('log_level_out_mini.csv', delimiter=';')
to:
data = pd.read_csv('log_level_out_mini.csv', delimiter=';', index_col=False)