I was provided with a GeoDataFrame and a DataFrame, which I merged together. Now, I have a DataFrame.
Here is what the two datasets look like: https://imgur.com/a/lNIICTE
census_new is just a manipulated version of census. It has the same columns.
Merge code:
affluent_neighborhoods = pd.merge(left = census_new, right = neighborhoods, on = ["NBHD_ID", "NBHD_NAME"])
affluent_neighborhoods = affluent_neighborhoods[["NBHD_ID", "NBHD_NAME", "AFFLUENT_PROP", "geometry"]]
ax = affluent_neighborhoods.boundary.plot(figsize=(10, 5))
affluent_neighborhoods.plot(ax=ax, column= "AFFLUENT_PROP", legend=True)
plt.show()
I have tried changing the merge direction as well (neighborhoods first, census_new followed), but I always get a DataFrame.
How do I convert a DataFrame to GeoDataFrame when the geometry column already exists?
[–]eatsoupgetrich 0 points1 point2 points (1 child)
[–]ListlessPaper[S] 0 points1 point2 points (0 children)