Skipping Rows When Reading a CSV into a Pandas Dataframe
Python
Import and Export
To skip rows when reading a csv into a Pandas dataframe, we can either pass a list of row indexes to skip into the skiprows parameter or we can pass an integer into the skiprows parameters which tells pandas how many rows to skip from the start of the csv.
In the below example we use both methods to skip the first 5 rows of the csv.
1| import pandas as pd 2| 3| # skip the first 5 rows 4| df = pd.read_csv('sales.csv', skiprows=5) 5| 6| # skip the rows indexed 0 to 4 7| rows_to_skip = [0, 1, 2, 3, 4] 8| df = pd.read_csv('sales.csv', skiprows=rows_to_skip)
2
Creating a Pandas DataFrame from a Python Generator
Python
Import and Export
2
2
2
Reading CSV Files from Amazon S3 into Pandas Dataframes
Python
Import and Export
1
Sklearn Iris Dataset - Load The Iris Dataset & Split Into Features & Target
Python
Import and Export
1
Using Selectors in Beautiful Soup to Scrape Using Classes & IDs
Python
Import and Export
1
1
1
Find the Nth Tag On a WebPage with Beautiful Soup
Python
Import and Export
1