Skip to content

Commit

Permalink
feat: update date handling to use 'date' column if available for year…
Browse files Browse the repository at this point in the history
…, month, and day calculations
  • Loading branch information
Ovler-Young committed Nov 30, 2024
1 parent de3d14b commit 9c3129f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/ia_collection_analyzer/streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,15 @@
# calculate metadata
data_transform_text.text("calculating metadata...")
items_pd["addeddate"] = pd.to_datetime(items_pd["addeddate"])
items_pd["publicdate"] = pd.to_datetime(items_pd["publicdate"])
# year and month should be recalculated
items_pd["year"] = items_pd["addeddate"].dt.year
items_pd["month"] = items_pd["addeddate"].dt.month
items_pd["day"] = items_pd["addeddate"].dt.day
# items_pd["publicdate"] = pd.to_datetime(items_pd["publicdate"])

# Use 'date' column if it exists, otherwise use 'addeddate'
date_column = "date" if "date" in items_pd.columns else "addeddate"

# year, month, and day should be recalculated
items_pd["year"] = pd.to_datetime(items_pd[date_column]).dt.year
items_pd["month"] = pd.to_datetime(items_pd[date_column]).dt.month
items_pd["day"] = pd.to_datetime(items_pd[date_column]).dt.day
data_transform_text.text("Data transformation and cleaning complete!")

# Update cache
Expand Down

0 comments on commit 9c3129f

Please sign in to comment.