0

I'm trying to import a csv of 20 rows of numbers using Pandas. For some reason, Pandas begins indexing it at the 2nd row "158" instead of the 1st row "164".

wrong indexing

Now when I try to perform a basic multiplication on it, it skips the first row of 164 and begins at the 2nd row when it should be performing on the first row as well. Why is the index beginning at the 2nd row?

multiply starting at 2nd row

Roger Qiu
  • 15
  • 6
  • 2
    `164` is assumed to be the header. Carefully read the [`read_csv`](https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html) docs for more detail. – BigBen Nov 01 '22 at 15:25
  • 2
    Please post code, data, and results as text, not screenshots. http://idownvotedbecau.se/imageofcode – Barmar Nov 01 '22 at 15:25
  • 1
    `read_csv(..., names=['weight'])` to have Pandas not interpret the first line as a header. – AKX Nov 01 '22 at 15:26
  • 1
    It assumes that the '164' is a header, try to read it with `header=None` --> pd.read_csv("weights.csv", header=None) – ggeop Nov 01 '22 at 15:32

0 Answers0