<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ worldweatheronline - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ worldweatheronline - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sun, 31 May 2026 09:39:30 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/worldweatheronline/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ Obtain Historical Weather Forecast data in CSV format using Python ]]>
                </title>
                <description>
                    <![CDATA[ By Ekapope Viriyakovithya Recently, I worked on a machine learning project related to renewable energy, which required historical weather forecast data from multiple cities. Despite intense research, I had a hard time finding the good data source. Mo... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/obtain-historical-weather-forecast-data-in-csv-format-using-python/</link>
                <guid isPermaLink="false">66d45e42d14641365a0508ac</guid>
                
                    <category>
                        <![CDATA[ worldweatheronline ]]>
                    </category>
                
                    <category>
                        <![CDATA[ api ]]>
                    </category>
                
                    <category>
                        <![CDATA[ csv ]]>
                    </category>
                
                    <category>
                        <![CDATA[ dataframe ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Machine Learning ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                    <category>
                        <![CDATA[ weather ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 09 Jul 2019 10:00:00 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9ca193740569d1a4ca4f62.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Ekapope Viriyakovithya</p>
<p>Recently, I worked on a machine learning project related to renewable energy, which required <strong>historical weather forecast data from multiple cities</strong>.</p>
<p>Despite intense research, I had a hard time finding the good data source. Most websites restrict the access to only past two weeks of historical data. If you need more, you need to pay. In my case, I needed five years of data — hourly historical forecast, which can be costly.</p>
<h3 id="heading-my-requirements-are"><strong>My requirements are...</strong></h3>
<p><strong>1. Free — at least during trial period</strong></p>
<p>No need to provide credit card info.</p>
<p><strong>2. Flexible</strong></p>
<p>Flexible to change forecast interval, time periods, locations.</p>
<p><strong>3. Reproducible</strong></p>
<p>Easy to reproduce and implement in the production phase.</p>
<p>In the end, I decided to use data from <a target="_blank" href="https://www.worldweatheronline.com/developer/api/historical-weather-api.aspx">World Weather Online</a>. This took me less than two minutes to subscribe free trial premium API — without filling credit card info. (500 free requests/key/day for 60 days, as of 30-May-2019).</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*kVPI57az2iE7Kjni3AhxOw.png" alt="Image" width="859" height="245" loading="lazy"></p>
<p><a target="_blank" href="https://www.worldweatheronline.com/developer/signup.aspx"><em>https://www.worldweatheronline.com/developer/signup.aspx</em></a></p>
<p>You can try out requests in JSON or XML format <a target="_blank" href="https://www.worldweatheronline.com/developer/premium-api-explorer.aspx">here</a>. The result is nested JSON which needed a bit pre-processing work before feeding into ML models. Therefore, I wrote some <a target="_blank" href="https://github.com/ekapope/WorldWeatherOnline">scripts</a> to parse them into pandas DataFrames and save as CSV for further use.</p>
<h3 id="heading-introducing-wwo-hist-package">Introducing wwo-hist package</h3>
<p>This <a target="_blank" href="https://pypi.org/project/wwo-hist/">wwo-hist package</a> is used to retrieve and parse historical weather data from <a target="_blank" href="https://www.worldweatheronline.com/developer/api/historical-weather-api.aspx">World Weather Online</a> into pandas DataFrame and CSV file.</p>
<p><strong>Input:</strong> api_key, location_list, start_date, end_date, frequency</p>
<p><strong>Output:</strong> location_name.csv</p>
<p><strong>Output column names:</strong> 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</p>
<h4 id="heading-install-and-import-the-package">Install and import the package:</h4>
<pre><code class="lang-py">pip install wwo-hist
</code></pre>
<pre><code class="lang-py"><span class="hljs-comment"># import the package and function</span>
<span class="hljs-keyword">from</span> wwo_hist <span class="hljs-keyword">import</span> retrieve_hist_data

<span class="hljs-comment"># set working directory to store output csv file(s)</span>
<span class="hljs-keyword">import</span> os
os.chdir(<span class="hljs-string">".\YOUR_PATH"</span>)
</code></pre>
<p><strong>Example code:</strong></p>
<p>Specify input parameters and call <strong><em>retrieve_hist_data()*</em></strong>.* Please visit <a target="_blank" href="https://github.com/ekapope/WorldWeatherOnline">my github repo</a> for more info about parameters setup.</p>
<p>This will retrieve <strong>3-hour interval</strong> historical weather forecast data for <strong>Singapore</strong> and <strong>California</strong> from <strong>11-Dec-2018</strong> to <strong>11-Mar-2019</strong>, save output into hist_weather_data variable and <strong>CSV</strong> files.frequency = 3</p>
<pre><code class="lang-py">FREQUENCY = <span class="hljs-number">3</span>
START_DATE = <span class="hljs-string">'11-DEC-2018'</span>
END_DATE = <span class="hljs-string">'11-MAR-2019'</span>
API_KEY = <span class="hljs-string">'YOUR_API_KEY'</span>
LOCATION_LIST = [<span class="hljs-string">'singapore'</span>,<span class="hljs-string">'california'</span>]

hist_weather_data = retrieve_hist_data(API_KEY,
                                LOCATION_LIST,
                                START_DATE,
                                END_DATE,
                                FREQUENCY,
                                location_label = <span class="hljs-literal">False</span>,
                                export_csv = <span class="hljs-literal">True</span>,
                                store_df = <span class="hljs-literal">True</span>)
</code></pre>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*Ga1fGBrxkoKgfzbu" alt="Image" width="795" height="747" loading="lazy"></p>
<p><em>This is what you will see in your console.</em></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*0-UJ7XO4ZG76oDlVvHQNVA.png" alt="Image" width="761" height="121" loading="lazy"></p>
<p><em>Result CSV(s) exported to your working directory.</em></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*gdtco3Zi0Kv03uz9" alt="Image" width="1200" height="245" loading="lazy"></p>
<p><em>Check the CSV output.</em></p>
<p>There you have it! The script detailed is also <a target="_blank" href="https://github.com/ekapope/WorldWeatherOnline">documented on GitHub</a>.</p>
<hr>
<p>Thank you for reading. Please give it a try, and let me know your feedback! If you like what I did, consider following me on <a target="_blank" href="https://github.com/ekapope">GitHub</a>, <a target="_blank" href="https://medium.com/@ekapope.v">Medium</a>, and <a target="_blank" href="https://twitter.com/EkapopeV">Twitter</a> to get more articles and tutorials on your feed.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
