Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Needed
#1
Hey All, Trying to get the below script to allow a user to input a storeID number; which then looks up the coordinates and inputs them into the variables. Can anyone help please? :)

import requests
import pandas as pd

df = pd.read_excel ('C:\Sites.xlsx')
print ("Please Enter the SiteID/No.:")
user = input("")
print (df.loc[df['SiteId'] == user]):
latitude = (df.loc[df['SiteLatitude'])
longitude = (df.loc[df['SiteLongitude'])

url = 'http://api.openweathermap.org/data/2.5/weather?lat={}&lon={}&appid=0c42f7f6b53b244c78a418f4f181282a&q&units=metric'.format(latitude, longitude)

res = requests.get(url)
data = res.json()
temp = data['main']['temp']
wind_speed = data['wind']['speed']
description = data['weather'][0]['description']
destination = data['name']

print('\nDestination : {}'.format(destination))
print('Temperature : {} Degree Celcius'.format(temp))
print('Wind Speed : {} m/s'.format(wind_speed))
print('Description : {}'.format(description))
EXCEL Sheet eg.

Output:
SiteId SiteName SiteClosedFlag SiteLatitude SiteLongitude 1 Sheffield Closed 53.3811 1.4701 2 Nottingham Open 52.9548 1.1581 3 Leeds Open 53.8008 1.5491 4 Wales Open 52.1307 3.7837
Reply
#2
user = int(input(""))
row = df.loc[df['SiteId'] == user]
latitude = row['SiteLatitude'][1]
longitude = row['SiteLongitude'][1]
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020