df = sample['geometry']
line_gdf = gpd.GeoDataFrame(geometry=[df[2],  df[3], df[4], df[5], df[6], df[7], df[8], df[9]])

Above is the manual process of selecting Line Strings

In order to select from 2:180 I tried some code without luck

line_gdf = gpd.GeoDataFrame(geometry=[df[df.rows[2:4]])

it comes up with an error of'GeoSeries' object has no attribute 'rows'

I am bit confused how to solve it I would appriciate some guidance.

1 Answer 1


Assuming "sample" is a GeoDataFrame, then df in your example is a GeoSeries of geometries. As GeoSeries don't have rows, df.rows give you the error you report.

Its unclear to me exactly what you are trying to achieve, but I assume you have a dataframe called sample, and you want to select rows 2 to 180. If so:

line_gdf = sample.iloc[2:180]

If you are trying to achieve something else, please clarify your inputs and desired outputs.

  • That is exactly what I was looking for !
    – Dominik M
    Commented Nov 25, 2019 at 10:00

Your Answer

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

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