'does pandas keep the order of rows when reading a file?
I have a large dataset, that I need to fetch some data with the help of URLs it holds, by the help of a loop through the indexes. I want to know if pandas keep the row order when reading a CSV file, according to the file order, so I can cut the rest and start from where it is left off.
df_contri_rep = pd.read_csv('contri_rep.csv',usecols=['url'])
If not, is there an option for this?
Solution 1:[1]
Python does keep the file in row order, you can also choose the number of rows you'd like to read and skip with pd.read_csv. The following would return the 100 rows (nrows) following the 500 rows skipped (skiprows) within your csv.
df_contri_rep = pd.read_csv('contri_rep.csv',usecols=['url'], skiprows=500, nrows=100)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ShyGuyRyRyNewlyTheDataGuy |
