课程: Hands-On Advanced Python: Data Engineering Basics
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Solution: Collections - Python教程
课程: Hands-On Advanced Python: Data Engineering Basics
Solution: Collections
- [Instructor] For this challenge, we needed to use the reduce method to find the most miserable day within the entire set of weather data. And the formula that we use to calculate this day takes into account, the wind speed maximum temperature and rainfall for each day, and gives us some combination of a hot, rainy, windy day. So my code to solve this problem uses two additional functions. The first function calculates the misery score for any given day within the dataset using the formula that we were provided as part of the instructions. All right, so that's this function right here, misery score. And one of the things you might have run into when working with this formula was that there were some instances in the dataset where the wind speed was none. And in those cases, I just set the wind speed value to zero. I then use this function in the callback that the reduce function, which is right here, uses to reduce the…