Skip to content
Advertisement

Count showing up as NaN

I’m on the last step of finishing my table, but my count is returning NaN. I’m trying to create a column target_days which groups by each value in ‘month_start_date’ and returns the value of the count of workday if True.

For example, each date that has a month_start_date of 2018-08-01 should return a value of 23 because there are 23 workdays in that month. Any help is appreciated!

JavaScript

Advertisement

Answer

Solution with groupby() and .transform(). Based on the response in this thread,

JavaScript

With that as a way to move forward, I was able to get the right solution.

JavaScript

The output of this is correct. The sample for month 2021-01-01 shows:

JavaScript

The first 100 rows have correct value count for holiday = True:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement