利用安居客获得的小区均价,通过百度地图开放平台获得小区经纬度坐标,然后利用folium绘制热力图
一、获得经纬度坐标
import pandas as pd
import requests
AK = "GFUlialWBG5GpLfZ6lK0oOWCoybMr6jH" # 在百度地图开放平台申请
data=pd.DataFrame()
def get_position(name, AK):
url = f'http://api.map.baidu.com/geocoding/v3/?address={name}&output=json&ak={AK}'
res = requests.get(url)
val = res.json()
bbb = {'地址': name,
'经度': val['result']['location']['lng'],
'纬度': val['result']['location']['lat'],
'地区标签': val['result']['level'],
'是否精确查找': val['result']['precise']}
return