March 2019
Beginner to intermediate
464 pages
10h 57m
English
We all know that there can only be 12 unique values for the month variable. Let's take a quick look at what we have in our dataset. Take a look at the following code:
df['month'].unique()
The pandas function, unique, helps you to quickly get the unique values in the given column. When you run this code, you will get the following output:

As expected, we have 12 unique values for the month column, from January to December. Since there is a natural ordering in the values of month, we can encode each of the values with a corresponding number. One way to encode the string values of month with numbers is shown as follows:
months ...
Read now
Unlock full access