I have a question about data frame processing.

Asked 2 years ago, Updated 2 years ago, 49 views

I loaded the csv file with Pandas.

Assigned to a variable called data.

Table of contents in the first row through for loop and

From the second line, I tried to make a code to express it through loop,

IndexError: The error positional indexes are out-of-bound keeps occurring

Here's a question.

I captured it to show you a picture of the result of printing(data).

Keep row 0 fixed and rotate for each person

I want to show you two lines each.

for i in range(1, len(data)):
    data = data.iloc[[0, i], ]
    print(data)

I wrote the code like this.

I didn't know what the problem was, so I changed the len(data) part to a number, but

An error occurs.

I'd appreciate it if you could tell me the answer!

dataframe pandas

2022-09-20 10:48

1 Answers

data = pd.read_csv(...,skiprows=1) The csv file appears to have non-data lines in front of it. With the skiprows factor, the lines can be skipped without being read. Let's clean this up first.


2022-09-20 10:48

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.