I have a shapefile that I am bringing in with geopandas. I do not need all the rows, just certain rows that start with 01, 02, and 03 for the route_id. I use a for loop and an if statement to try to append the data I want to an empty dataframe. Below is the sample Data:
ROUTE_ID | FROM_MEASU | TO_MEASURE | STREET_PRE | BASE_NAME |
---|---|---|---|---|
0100006595050034-D | 5.799725 | 9.678965 | 215th | |
0200006595050034-D | 0 | 9.678965 | ST | 220th |
0300006595050034-D | 5.799725 | 9.678965 | 215th | |
0400006595050034-D | 0 | 9.678965 | ST | 220th |
my code is as follows:
mnlrshwy = pd.DataFrame(columns=['ROUTE_ID','FROM_MEASU','TO_MEASURE','STREET_PRE',
'BASE_NAME'])
for x in mnlrs['ROUTE_ID']:
if x.startswith(('01','02','03')) is True:
mnlrshwy = x.append(mnlrs,ignore_index = True)
I get a concatenation error which I don't understand why I would get something like that. Any suggestions would be helpful.