0

I am trying to use the CategoricalDtype for a column by the name 'calendar month' to order the values in it from January through December. It is however NOT outputting the correct results. Not sure what I am doing wrong. Can someone please help?

Call outs:

  1. I have two Categorical Objects in my code.

  2. Categorical Object 1: calendar_year_sorted. This object works perfectly and is executed before the second categorical object. Partial code for this object is below and works perfectly: calendar_year_sorted = CategoricalDtype(['2020', '2021', '2022', '2023'], ordered=True)

  3. Categorical Object 2: calendar_month_sorted. This is the object which is not working and is executed after the first object. Complete code for this object is below.

Checking Initial Values

Checking initial values

Using Categorical Object

Creating object

qa

qa

I was hoping that the output will NOT make all the values except the month of September as 0.

0 Answers0