Graded Assignment 2: Open Data with Pandas
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
Graded Assignment 2: Open Data with Pandas(Update)
● Save the file name format as:
○ Dept_Year_GroupID_StudentName_ExerciseNumber.py
○ e.g.: EIE-DG2-TRN001_Chan_TaiMan_TMA1.py
● Show question number and suppress irrelevant outputs on the command window.
With refer to the local weather data example in the Lesson, i.e.
https://data.weather.gov.hk/weatherAPI/opendata/weather.php?dataType=rhrread&lang=en
1. Complete the Python function getData to collect data and combine the data forming a Dataframe, weather as illustrated below. Design your unit test cases and display the result.
2. Complete the Python function name “getTempRain” to return the Temperature and Rainfall data from the DataFrame weather for a given region. Design your unit test cases and display the result.
- If the region is not in the valid region list, the value for both return parameters nTemp and nRain should be equal to -1.
- If the weather station in the region has no Thermometer, the value of temperature will set to be -1.
- If the weather station in the region has no Rain gauge, the value of Rain fall will set to be -1 def
getTempRain (Region, weather)
3. Complete a Python function name “Report” to output the current weather report to the console with the following prototype. Design your unit test cases and display the result.
def Report(Place, cTemp, cRain, cDate, cTime)
Remark:
- Use one decimal place for temperature and rainfall data
- If both cTemp and cRain are equal to -1, the following message should be displayed no record for Region
- If cTemp is equal to -1, no temperature information should be displayed
- If cRain is equal to -1, no rainfall information should be displayed
- If rainfall is less than 0.05mm, the message “No rainfall for the last hour” should be displayed.
The layout of the report should be same as following examples
4. Complete the command line program weather.py to show the current weather for a user input. Submit your code with the screen captures for demonstrating your program with test cases.
2021-11-18