From the course: Hands-On Advanced Python: Data Engineering Basics
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Solution: Transforms - Python Tutorial
From the course: Hands-On Advanced Python: Data Engineering Basics
Solution: Transforms
- [Instructor] Alright, so for this challenge, we needed to transform the weather data records from dictionaries with keys and values into a list of tuples that contained only the existing date value and a string that indicated whether the day was cold or warm or hot. So here is how I solved this challenge. First, my code needs to import the JSON module and then open the weather data file. And we've already seen how to do this. So once I've got the weather data loaded and parsed, I'm going to perform the transformation, and I use the map function, which you can see down here, right, and the map function requires a callback to perform the actual mapping from the dictionary format to the tuple format. So my callback function basically takes an average temperature and describes it as a descriptor. So the first line of code calculates the average temperature and then based upon whether that average temperature is below 60…