I have a file or dataframe like below containing city name , latitude and longitude.
city.head(4)
City Latitude Longitude
Seattle 47.620422 122.349358
Dubai 25.276987 55.296249
Mexico 19.432608 99.1332
Tokyo 35.652832 139.839478
I want pass all the lattitude and longitude from city dataframe to an API and get the corresponding results. Currently I able to pass providing feeding lat and long as input to the parms.
How can I automate the entire steps. Lat and Long should be passed into params in this format lat:long****( first 3 decimals points should be extracted from the city dataframe)
import requests
headers = {
'Authorization': 'Api-Key ',
}
params = (
('coords', '49.910:10.920, 47.620:122:349'),
)
response = requests.get('https://api.example.com/we/v12/forecasts', headers=headers, params=params)
Sample Output of API
'{"results":[{"place":{"type":"locode","value":"PLWRO"},"measures":[{"ts":1572177600000,"t2m":19.6,"t_min":12.16,"t_max":20.59,"wspd":26,"dir":"W","wgust":37,"rh2m":44,"prsmsl":1015,"skcover":"clear","precip":0.0,"snowd":0,"thunderstorm":"N","fog":"L"}]},{"place":{"type":"locode","value":"DEHAM"},"measures":[{"ts":1572177600000,"t2m":10.49,"t_min":8.18,"t_max":10.6,"wspd":21,"dir":"W","wgust":39,"rh2m":69,"prsmsl":1016,"skcover":"partly_cloudy","precip":0.0,"snowd":0,"thunderstorm":"N","fog":"L"}]}]}'
How can this be done.