
There you have it! The script detailed is also documented on GitHub. Result CSV(s) exported to your working directory. Store_df = True) This is what you will see in your console. Hist_weather_data = retrieve_hist_data(API_KEY, This will retrieve 3-hour interval historical weather forecast data for Singapore and California from 1 to 1, save output into hist_weather_data variable and CSV equency = 3 FREQUENCY = 3 Please visit my github repo for more info about parameters setup. Specify input parameters and call retrieve_hist_data(). # set working directory to store output csv file(s) 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 and import the package: pip install wwo-hist # import the package and function Input: api_key, location_list, start_date, end_date, frequency This wwo-hist package is used to retrieve and parse historical weather data from World Weather Online into pandas DataFrame and CSV file. Therefore, I wrote some scripts to parse them into pandas DataFrames and save as CSV for further use. The result is nested JSON which needed a bit pre-processing work before feeding into ML models. You can try out requests in JSON or XML format here. (500 free requests/key/day for 60 days, as of 3). This took me less than two minutes to subscribe free trial premium API - without filling credit card info. In the end, I decided to use data from World Weather Online. My requirements are.įlexible to change forecast interval, time periods, locations.Įasy to reproduce and implement in the production phase. In my case, I needed five years of data - hourly historical forecast, which can be costly.

Most websites restrict the access to only past two weeks of historical data. Recently, I worked on a machine learning project related to renewable energy, which required historical weather forecast data from multiple cities.ĭespite intense research, I had a hard time finding the good data source.
