October 2019
Beginner to intermediate
674 pages
16h 43m
English
We can also skip certain rows. Let's say that we only want the rows whose indices are multiples of 3:
from io import StringIOdata = 'col1,col2,col3\na,b,1\na,b,2\nc,d,3\nc,e,4\ng,f,5\ne,z,6'pd.read_csv(StringIO(data),skiprows=lambda x: x % 3 != 0)
We get the following output:

The left-hand side diagram shows the resultant DataFrame without skipping any row, while the right-hand side shows the same DataFrame after filtering the ...
Read now
Unlock full access