【发布时间】:2021-05-31 15:04:23
【问题描述】:
我有一个表名Rides:
| start_lat | start_long | end _lat | end_long |
|---|---|---|---|
| 29.682413 | 78.997065 | 27.682413 | 76.997065 |
| 25.682413 | 74.997065 | 24.682413 | 76.997065 |
我想将它们转换为 h3 单元格并将它们添加回表格。我正在使用以下代码:
lst1=[]
lst2=[]
for i in range(rides.shape[0]):
hex1,hex2=0,0
hex1 = h3.geo_to_h3(rides['start_lat'][i],rides['start_long'][i], 8)
hex2 = h3.geo_to_h3(rides['end_lat'][i],rides['end_long'][i], 8)
lst1.append(hex1)
lst2.append(hex2)
rides['hex_ID1'] = lst1
rides['hex_ID1'] = lst2
这需要很多时间,我在想是否有更快的方法来做到这一点。
【问题讨论】:
标签: python pandas dataframe loops h3