D:\Users\z84259074\PycharmProjects\hotspot\GUI.py:193: UserWarning: Boolean Series key will be reindexed to match DataFrame index. thr_grid = thr_grid[data_grid['Latitude'] < (float(self.topLeftLatitude)-(0.00001 * 50))] D:\Users\z84259074\PycharmProjects\hotspot\GUI.py:193: UserWarning: Boolean Series key will be reindexed to match DataFrame index. thr_grid = thr_grid[data_grid['Latitude'] < (float(self.topLeftLatitude)-(0.00001 * 50))] Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\z84259074\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1921, in __call__ return self.func(*args) File "D:\Users\z84259074\PycharmProjects\hotspot\GUI.py", line 119, in zoomout self.update_map() File "D:\Users\z84259074\PycharmProjects\hotspot\GUI.py", line 104, in update_map img=self.draw_grid(img) File "D:\Users\z84259074\PycharmProjects\hotspot\GUI.py", line 209, in draw_grid grid_layer=self.hot_map(thr_grid,4) File "D:\Users\z84259074\PycharmProjects\hotspot\GUI.py", line 225, in hot_map heatmap[int(longitude), int(latitude)] += intensity[k] TypeError: only size-1 arrays can be converted to Python scalars报错修改
时间: 2023-08-04 21:07:38 浏览: 239
读书笔记:hotspot实战的测试demo.zip
在你的代码中,出现了一些警告和错误。警告是由于在使用布尔索引时,DataFrame的形状发生了变化,而导致的重新索引警告。错误是由于尝试将数组赋值给标量变量时导致的类型错误。
为了修复这些问题,你需要对代码进行以下修改:
1. 首先,解决警告问题。你可以使用`loc`方法来选择符合条件的行,以避免形状变化和重新索引问题。修改如下:
```python
thr_grid = thr_grid.loc[thr_grid['Latitude'] < (float(self.topLeftLatitude) - (0.00001 * 50))]
```
2. 其次,修复类型错误。在循环中,将`int(longitude)`和`int(latitude)`作为索引时,应该使用`int(latitude[k])`和`int(longitude[k])`来获取对应的经度和纬度值。修改如下:
```python
heatmap[int(latitude[k]), int(longitude[k])] += intensity[k]
```
经过以上修改,代码应该能够正常运行并生成热力图。如果还有其他错误,请提供更多的错误信息以便进一步排查。
阅读全文