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.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
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 the 5 rows from the 100000th gdf = gpd.read_file("/path/to/my/shapefile.shp", rows=slice(100000, 100005))
import geopandas as gpd import fiona c = fiona.open(r'C:\someshapefile.shp') df = gpd.GeoDataFrame.from_features(c[0:5])