【发布时间】:2019-03-17 13:49:31
【问题描述】:
问题
我正在尝试使用 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 值。
我该如何解决这个问题?
【问题讨论】:
-
你想用
xa[xa < 0] = -1做什么?这是无效的语法。 -
您的 Extortion 列中有负值吗?
-
@NoSplitSherlock 这不是我的代码。尤其是错误指向的位置。它在 Anaconda3\lib\site-packages\matplotlib\colors.py:504
-
@martinfleis 不,没有任何负值。勒索列具有正浮点值
-
@Pubz 这似乎是 GeoPandas 或 matplotlib 中的错误。您使用的是什么版本?