Code Monkey home page Code Monkey logo

worldweatheronline's Introduction

WorldWeatherOnline historical weather data API wrapper

Downloads

This package is used to retrieve and transform historical weather data from www.worldweatheronline.com into pandas dataframe and csv.

You can get API key for free (free trial 500 requests/key/day for 60 days, as of 30-May-2019).

example API explorer: https://www.worldweatheronline.com/developer/premium-api-explorer.aspx

Input: api_key, location_list, start_date, end_date, frequency

Output: location_name.csv

Output column names: date_time, maxtempC, mintempC, totalSnow_cm, sunHour, uvIndex, uvIndex, moon_illumination, moonrise, moonset, sunrise, sunset, DewPointC, FeelsLikeC, HeatIndexC, WindChillC, WindGustKmph, cloudcover, humidity, precipMM, pressure, tempC, visibility, winddirDegree, windspeedKmph

Install the package:

pip install wwo-hist

Import package

from wwo_hist import retrieve_hist_data

Set working directory to store output csv file(s)

import os
os.chdir(".\YOUR_PATH")

Example code

frequency=3
start_date = '11-DEC-2018'
end_date = '11-MAR-2019'
api_key = 'YOUR_API_KEY'
location_list = ['singapore','california']

hist_weather_data = retrieve_hist_data(api_key,
                                location_list,
                                start_date,
                                end_date,
                                frequency,
                                location_label = False,
                                export_csv = True,
                                store_df = True)

Parameters:

api_key: string

(Premium/ free trial) API key from https://www.worldweatheronline.com/developer/api/

location_list: list of string

US Zipcode, UK Postcode, Canada Postalcode, IP address, Latitude/Longitude (decimal degree) or city name

start_date: string

Preferred date format: 'dd-mmm-yyyy'

end_date: string

Preferred date format: 'dd-mmm-yyyy'

frequency: integer

1, 3, 6, 12, 24

1 hourly, 3 hourly, 6 hourly, 12 hourly (day/night) or 24 hourly (day average)

location_label: bool, default = False

If True, all column names will have city name as prefix.

export_csv: bool, default = True

If False, no csv file will be exported to current directory.

store_df: bool, default = False

If True, retrieved dataframe(s) will be stored as list in the work space.

Console view

IPython

Output file

CSV file

worldweatheronline's People

Contributors

ekapope avatar evangoldconn avatar zack-kimble avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.