Machine Learning News Hubb
Advertisement Banner
  • Home
  • Machine Learning
  • Artificial Intelligence
  • Big Data
  • Deep Learning
  • Edge AI
  • Neural Network
  • Contact Us
  • Home
  • Machine Learning
  • Artificial Intelligence
  • Big Data
  • Deep Learning
  • Edge AI
  • Neural Network
  • Contact Us
Machine Learning News Hubb
No Result
View All Result
Home Machine Learning

Forecast Your Weather With Python Script | by prkskrs | Catalysts | Sep, 2022

admin by admin
September 9, 2022
in Machine Learning


What we are going to build ?

→ In order to check your place’s weather. With the help of inbuilt libraries of python like requests, json and IPython. From “IPython” library , we use modules like “Image” and “display”.

Step 1 : Importing Dependencies

import requests
import json
from IPython.display import Image, display

Step 2 : Enter your api-key
→
You can use https://api.openweathermap.org/ and get your API key. So that, you will get access of data.

# api-key
appId="944e28e*********************"

Step 3 : Enter your place name

# place input
query=input("Enter Your Place to Check Weather : ")

Step 4 : Make queries for URL
→
Here you can write more specific queries for URL.

# queries
unit="metric"

Step 5 : Create Dynamic URL
→
Design your URL. With query variables and make sure that you are using api key or id.

# API url
url="https://api.openweathermap.org/data/2.5/weather?q="+f"{query}"+"&appid="+f"{appId}"+"&units="+f"{unit}"

Step 6 : Send GET request and store response of URL hit

# get response from api-hit
response=requests.get(url,stream=True)

Step 7 : Store data from response

# get data (in bytes form)
data=response.content

Step 8 : Convert “bytes” format to json

# get json file from "bytes" type
jsn=json.loads(data.decode("utf-8"))

Step 9 : Store important data from converted json file

# get temperature
temp=jsn["main"]["temp"]
# get weather icon
icon=jsn["weather"][0]["icon"]
# get weather description
weatherDesc=jsn['weather'][0]["description"]

Step 10 : Send GET request and store response of URL to fetch Image

# get request with imageUrl to fetch png image
imageUrl="https://openweathermap.org/img/wn/"+f"{icon}"+"@2x.png"
response2=requests.get(imageUrl,stream=True)

Step 11 : Display Outputs

# display png
display(Image(response2.content))
# display temperature
print(f"Temperature : {temp}°C (Degree Celcius)")
# display place name
print(f"Place : {query}")
# display weather description
print(f"Weather Description : {weatherDesc}")

Sample Output :

Github Link For Full Code : Click Here





Source link

Previous Post

How Amp on Amazon used data to increase customer engagement, Part 1: Building a data analytics platform

Next Post

Why You Have To Learn GIT Right Now If You Are a Beginner in Data Science | by Federico Trotta | Sep, 2022

Next Post

Why You Have To Learn GIT Right Now If You Are a Beginner in Data Science | by Federico Trotta | Sep, 2022

Build repeatable, secure, and extensible end-to-end machine learning workflows using Kubeflow on AWS

Graphs as Scikit-Learn metaestimators | by Big-O | Sep, 2022

Related Post

Artificial Intelligence

Dates and Subqueries in SQL. Working with dates in SQL | by Michael Grogan | Jan, 2023

by admin
January 27, 2023
Machine Learning

ChatGPT Is Here To Stay For A Long Time | by Jack Martin | Jan, 2023

by admin
January 27, 2023
Machine Learning

5 steps to organize digital files effectively

by admin
January 27, 2023
Artificial Intelligence

Explain text classification model predictions using Amazon SageMaker Clarify

by admin
January 27, 2023
Artificial Intelligence

Human Resource Management Challenges and The Role of Artificial Intelligence in 2023 | by Ghulam Mustafa Shoaib | Jan, 2023

by admin
January 27, 2023
Deep Learning

Training Neural Nets: a Hacker’s Perspective

by admin
January 27, 2023

© 2023 Machine Learning News Hubb All rights reserved.

Use of these names, logos, and brands does not imply endorsement unless specified. By using this site, you agree to the Privacy Policy and Terms & Conditions.

Navigate Site

  • Home
  • Machine Learning
  • Artificial Intelligence
  • Big Data
  • Deep Learning
  • Edge AI
  • Neural Network
  • Contact Us

Newsletter Sign Up.

No Result
View All Result
  • Home
  • Machine Learning
  • Artificial Intelligence
  • Big Data
  • Deep Learning
  • Edge AI
  • Neural Network
  • Contact Us

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.