Skip to content

Commit

Permalink
fix(generate_reports_data): change dataformats for non-deprecated com…
Browse files Browse the repository at this point in the history
…parisons
  • Loading branch information
V committed Jan 8, 2025
1 parent b3ea87b commit d2e913f
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions reports/generate_reports_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ def _rt_completeness():


def generate_rt_completeness(itp_id: int, date_start: str, date_end: str):
df = _rt_completeness()
df = _rt_completeness() # service_date format: datetime64, 'YYYY-MM-DD 00:00:00'
date_start = pd.to_datetime(date_start)
date_end = pd.to_datetime(date_end)

# Filter the DataFrame based on the conditions
return df[
return df[ # Why doesn't this comparison fail? like the other comparisons?
(df["calitp_itp_id"] == itp_id)
& (df["service_date"] >= date_start)
& (df["service_date"] <= date_end)
Expand Down Expand Up @@ -179,9 +179,16 @@ def _median_tu_age():


def generate_ave_median_tu_age(itp_id: int, date_start, date_end):
df = _median_tu_age()
date_start = pd.to_datetime(date_start)
date_end = pd.to_datetime(date_end)
"""
Args:
itp_id (int): The ITP ID to filter the DataFrame.
date_start (str): The start date of the range in 'YYYY-MM-DD' format.
date_end (str): The end date of the range in 'YYYY-MM-DD' format.
"""
df = _median_tu_age() # service_date format: datetime64[ns], 2025-01-05 00:00:00

date_start = pd.Timestamp(date_start)
date_end = pd.Timestamp(date_end)

# Filter the DataFrame based on the conditions
return df[
Expand Down Expand Up @@ -224,9 +231,16 @@ def _median_vp_age():


def generate_ave_median_vp_age(itp_id: int, date_start, date_end):
df = _median_vp_age()
date_start = pd.to_datetime(date_start)
date_end = pd.to_datetime(date_end)
"""
Args:
itp_id (int): The ITP ID to filter the DataFrame.
date_start (str): The start date of the range in 'YYYY-MM-DD' format.
date_end (str): The end date of the range in 'YYYY-MM-DD' format.
"""
df = _median_vp_age() # service_date format: object, 'YYYY-MM-DD'
df["service_date"] = pd.to_datetime(df["service_date"])
date_start = pd.Timestamp(date_start)
date_end = pd.Timestamp(date_end)

# Filter the DataFrame based on the conditions
return df[
Expand Down

0 comments on commit d2e913f

Please sign in to comment.