in src/smjsindustry/finance/utils.py [0:0]
def _get_freq_label_by_year(date_value: str) -> str:
"""Gets frequency label for the date value which is aggregated by year.
Args:
date_value (str): The date value.
Returns:
str: The date value aggregated by year.
"""
if bool(re.match(r"^\d{4}$", date_value)):
return date_value
if not bool(re.match(r"^\d{4}(-\d{1,2}){0,2}$", date_value)):
raise ValueError("Date needs to be in yyyy-mm-dd, yyyy-mm or yyyy format when freq is Y")
ts = pd.Timestamp(date_value)
return str(ts.year)