I used pysal/cenpy to extract geo info, but the object is returning errors by calling centroid
import cenpy as cen
import pysal as ps
import geopandas as gpd
dataset = 'ACSSF5Y2015'
con = cen.base.Connection(dataset)
con.set_mapservice('tigerWMS_ACS2017')
geotmp = con.mapservice.query(layer=84, where='STATE=' + str(1))
type(geotmp)
#pandas.core.frame.DataFrame
type(geotmp.geometry[0])
#pysal.cg.shapes.Polygon
geotmp.geometry.centroid
AttributeError: 'Series' object has no attribute 'centroid'
Checked the same on a built-in dataset from the gds-scipy16
type(data_table)
#pandas.core.frame.DataFrame
type(data_table.geometry[0])
#pysal.cg.shapes.Polygon
data_table.geometry[0].centroid
#(-94.90336786329912, 48.771730563701574)
How to correct the error?
Although this does not directly answer your question, there is a newer pre-release version of
cenpy
out that is much more streamlined and will avoid the problem you describe above (see example below). Instructions for installing the pre-release can be found here and a gist demonstrating functionality here.