uga-libraries / hub-audit

Compare the Digital Production Hub share contents to the inventory, to identifying information that needs updating.
Creative Commons Attribution Share Alike 4.0 International
0 stars 0 forks source link

Date comparison error if all dates expired #5

Open amhanson9 opened 5 months ago

amhanson9 commented 5 months ago

With the function check_dates(), I discovered during unit testing that if every date is in the past, it was classified as a pandas timestamp (class pandas._libs.tslibs.timestamps.Timestamp. This was causing the dates to be classified as nondate, giving the following error: AttributeError: Can only use .str accessor with string values!

I added the pandas timestamp to determining if something is a date. Even though the expired dates are in df_date, and df_nondate is empty, it still gives the AttributeError from the line df_nondate.loc[df_nondate['Review_Date'].str.lower()... This is not a problem for the unit test that is all future dates, which also has an empty datatframe for df_nondate.

In practice, this is unlikely to happen. The dataframe is every row from every share inventory, so there will be some dates in the future and some dates that are text. For now, I'll keep a permanent date in the test for dates_expired. Try to figure it out later in case it is pointing to a problem I'm missing.

amhanson9 commented 5 months ago

Is there a way to make Review_Date be datetime for ones that are dates, given that there are also strings in this one? If so, I could do that in read_inventory()