Pandas has a parameter nrows for selecting how many rows will be read into the DataFrame.

Does GeoPandas have a similar parameter? Couldn't find in the documentation.

2 Answers 2


Geopandas 0.7 added a new rows parameter to read_file. You can use it to read the first n rows, or a specific slice of rows.

import geopandas as gpd

# Read the first 100 rows
gdf = gpd.read_file("/path/to/my/shapefile.shp", rows=100)

# Read 5 rows from the 100000th
gdf = gpd.read_file("/path/to/my/shapefile.shp", rows=slice(100000, 100005))

  • great answer! do you know if R has an equivalent?
    – stats_noob
    Apr 2 at 15:14

See Only read specific rows of a shapefile with GeoPandas / Fiona:

import geopandas as gpd
import fiona

c = fiona.open(r'C:\someshapefile.shp')
df = gpd.GeoDataFrame.from_features(c[0:5])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.