1

I have a large input file of numerical data (22000) columns and at the moment when I use
df = pd.read_csv(path_to_file), it uses the first line of numbers as the column values.

Is there any way to replace the column value with random variables or load the data in a way that the first line is not used as a column name?

MarianD
  • 13,096
  • 12
  • 42
  • 54
msa
  • 693
  • 6
  • 21
  • 1
    Does this answer your question? [Pandas read in table without headers](https://stackoverflow.com/questions/29287224/pandas-read-in-table-without-headers) – talatccan Mar 07 '20 at 11:30

2 Answers2

0

Use pd.read_csv("path_to_file", header=0).

If you also want to assign names to the columns you can pass a list in the names parameter of pd.read_csv.

peterhunter
  • 76
  • 1
  • 5
0

Use the parameter header=None:

df = pd.read_csv(path_to_file, header=None)

Then column names will be 0, 1, 2, ..., 21999, and all rows in your CSV-file will be treated as data rows.

If you are not satisfied with those automatically assigned column names, you may change them as in this answer of the question “How to name Pandas Dataframe Columns automatically?

MarianD
  • 13,096
  • 12
  • 42
  • 54