1

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?

3
  • Please do not post data or code (as in your «Result») as screenshots but rather as text. Please also provide a reproducible example. Commented Jul 9, 2022 at 5:31
  • see if this helps pandas.pydata.org/docs/reference/api/… Commented Jul 9, 2022 at 5:32
  • Did you check the docs about index_col parameter of read_cav? Commented Jul 9, 2022 at 5:47

1 Answer 1

2

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)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.