I have a DataFrame that I want to split into two different DataFrames so I can plot them with GeoPandas later.
price Latutude Longitude yr_built geometry pl
0 530000.0 -122.394 -122.394 1900 POINT (-122.39400 47.67000) 13.180632
1 740500.0 -122.368 -122.368 1900 POINT (-122.36800 47.69810) 13.515081
2 625000.0 -122.390 -122.390 1900 POINT (-122.39000 47.58720) 13.345507
3 595000.0 -122.345 -122.345 1900 POINT (-122.34500 47.65820) 13.296317
4 485000.0 -122.370 -122.370 1900 POINT (-122.37000 47.63850) 13.091904
There are yr_built that go from 1900-2015.
I tried to split it like this:
geoSub1910_1960 = pd.DataFrame()
geoSub1961_2015 = pd.DataFrame()
gdf['yr_built']= gdf['yr_built'].astype(int)
for i in range(len(gdf)):
print(gdf.iloc[i,:])
print('this is seperated')
if gdf['yr_built'] <= 1960:
geoSub1910_1960.append(gdf.iloc[i,:], ignore_index=True)
else:
geoSub1961_2015.append(gdf.iloc[i,:], ignore_index=True)
The Error that I get is:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().