问题
我试着用geopandas绘制每个地区的犯罪数据。我合并了shapefile数据和犯罪数据:
merged = merged[['geometry','Extortion']]
merged.head()

尝试
然后,我试图在地图上绘制犯罪数据:
variable = 'Extortion'
vmin, vmax = 120, 220
fig, ax = plt.subplots(1, figsize=(20, 10))
merged.plot(variable, cmap='Blues', linewidth=0.8, ax=ax, edgecolor='0.8')错误
C:\Users\Navoda\Anaconda3\lib\site-packages\matplotlib\colors.py:504:
RuntimeWarning: invalid value encountered in less
xa[xa < 0] = -1如果没有参数“变量”,它将加载到基映射中。问题在于变量。我试着按照大多数帖子的建议关闭警告。它仍然没有装载犯罪数据。
我检查了错误的位置。但是,我不知道原因。
代码
if xa.dtype.kind == "f":
xa *= self.N
# Negative values are out of range, but astype(int) would truncate
# them towards zero.
xa[xa < 0] = -1
# xa == 1 (== N after multiplication) is not out of range.
xa[xa == self.N] = self.N - 1
# Avoid converting large positive values to negative integers.
np.clip(xa, -1, self.N, out=xa)
xa = xa.astype(int)注意:勒索栏没有NaN值。
我该如何解决这个问题?
发布于 2019-12-03 00:56:51
我得到了同样的错误,在检查时,它是由形状文件中的多边形没有在数据中表示,所以它只需要替换在合并时创建的NANs,例如
merged['Extortion']=merged['Extortion'].fillna(0)https://stackoverflow.com/questions/55207756
复制相似问题