1. Învăţa
  2. /
  3. Courses
  4. /
  5. Analyzing Police Activity with pandas

Connected

exercise

Rating the weather conditions

In the previous exercise, you counted the number of bad weather conditions each day. In this exercise, you'll use the counts to create a rating system for the weather.

The counts range from 0 to 9, and should be converted to ratings as follows:

  • Convert 0 to 'good'
  • Convert 1 through 4 to 'bad'
  • Convert 5 through 9 to 'worse'

Instrucţiuni

100 XP
  • Count the unique values in the bad_conditions column and sort the index. (This has been done for you.)
  • Create a dictionary called mapping that maps the bad_conditions integers to the specified strings.
  • Convert the bad_conditions integers to strings using the mapping and store the results in a new column called rating.
  • Count the unique values in rating to verify that the integers were properly converted to strings.