Last answered:

11 May 2023

Posted on:

10 May 2023

0

Quiz Answer Explaination

I do not understand the answer of the quiz that python expects missing values when using 'b' instead of 'd'

as the dataframe shows that even after using 'b', non-business days disappear so they were not been expected, they are omitted instead


Can someone please explain the answer please?


1 answers ( 0 marked as helpful)
Instructor
Posted on:

11 May 2023

0

Hello Eslam,


Thanks for reaching out.


When setting the argument to "b" in the freq parameter of the asfreq method, Python understands that the data should be aligned to business days, excluding weekends. This means that if a date falls on a Saturday or Sunday, which are non-business days, Python will recognize those as missing values.

On the other hand, if you were to set the argument to "d" in the freq parameter, it would imply that the data needs to be recorded exactly once per day, regardless of whether it falls on a weekend or not. This means that if a date falls on a Saturday or Sunday, Python would still attempt to record the data for that day, even though it might not be available or relevant.

In finance-related applications, it is often more appropriate to align data with business days and exclude weekends, as financial markets typically operate on weekdays. By using "b" as the frequency, you ensure that your analysis takes into account the absence of data on weekends, providing more accurate results and avoiding potential issues that could arise from including non-business days in financial calculations.


Hope this helps.


Best,

The 365 Team

Submit an answer