From the course: Python Data Analysis

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Weather anomalies

Solution: Weather anomalies - Python Tutorial

From the course: Python Data Analysis

Start my 1-month free trial

Solution: Weather anomalies

(upbeat music) - [Instructor] We start by importing getWeather, since we need temperature data. It will also be good to show smoothed plots, so we'll grab the smooth function that we made. We need all the available historical data for New York, say 1880 through 2019, which we collect in a stacked array. We sum TMIN and TMAX for this large array and then take the average across the columns. So x is equal one, so that we get a value for each year. The shape isn't yet what we expect. Next, the mid-century average. We need to figure out the index of 1945 and 1955, in this all avg array. For lists, we can use index to figure out the location of an element. But unfortunately, that doesn't work for NumPy arrays. However, we can turn array into lists quite easily by feeding them to the list constructor, and then index works. So now we can perform the mid-century average over the correct slice of the array. It's 12.8…

Contents