If/Then Conditional statement with Time Data

Viewed 30

I am running into and issue where I cannot compare date values between two data frames using Pandas.

I have two data frames loan_data & fiscal_periods. Both contain start and stop dates. I need to calculate the start & stop dates for the time the loan was in the period so that I can calculate the days the loan was in the period. Example:

From loan_data loan_start 2022-01-07 loan_end 2022-07-25

From fiscal_periods period_start 2022-06-26 period_end 2022-07-30

The loan was in the period for 29 days

    p10_start = loan_start
else:
    p10_start = period_start
    
if loan_end <= period_end:
    p10_end = loan_end
else:
    p10_end = period_end```

This formula needs help!! Any suggestions on how to compare dates between two data frames and return the value requested?

Thanks


0 Answers
Related