How to read a specific line number in a csv with pandas

后端 未结 4 2047
盖世英雄少女心
盖世英雄少女心 2021-01-18 10:46

I have a huge dataset and I am trying to read it line by line. For now, I am reading the dataset using pandas:

df = pd.read_csv(\"mydata.csv\", sep =\',\', n         


        
4条回答
  •  旧巷少年郎
    2021-01-18 11:23

    You are using nrows = 1, wich means "Number of rows of file to read. Useful for reading pieces of large files"

    So you are telling it to read only the first row and stop.

    You should just remove the argument to read all the csv file into a DataFrame and then go line by line.

    See the documentation for more details on usage : https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html

提交回复
热议问题