Skip Rows During CSV Import with Python Pandas

In this tutorial, we will learn how to skip rows during csv import with Python Pandas. To skip rows during csv import with Python Pandas, we can call read_csv with the skiprows argument.

Example:

import pandas as pd
from StringIO import StringIO

s = """1, 2
3, 4
5, 6"""

df = pd.read_csv(StringIO(s), skiprows=[1], header=None)
  • To call read_csv with the StringIO object with csv string s.
  • We set skiprows to [1] to skip the 2nd row.
  • And we set header to None to skip parsing the header.

#python 

1.45 GEEK