Skip to content

Commit

Permalink
Auto-merged main into task/precompute-stats/2897 on deployment.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgboss authored Nov 24, 2023
2 parents 3fbed35 + b574ec3 commit e62c64f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 48 deletions.
96 changes: 53 additions & 43 deletions api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fastapi = "^0"
requests = "^2"
aiodns = "^3"
aiohttp = "^3"
pandas = "^1"
pandas = "^2"
pyjwt = "^2"
cryptography = "^41.0.4"
sqlalchemy = "^2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def main():
continue

season = get_core_fire_season(station)
remove_data_outside_fire_season(station_df, season)
station_df = remove_data_outside_fire_season(station_df, season)
percentiles = calculate_percentile(station_df, PERCENTILE)

years = get_years_for_valid_fwi_values(station_df)
Expand Down Expand Up @@ -127,15 +127,17 @@ def remove_data_outside_fire_season(df: pd.DataFrame, season: dict):
""" Remove data recorded outside of fire season. """
outside_month = (df['month'] < season['start_month']) | (
df['month'] > season['end_month'])
df.drop(df[outside_month].index, inplace=True)
df = df.loc[~outside_month]

before_start = ((df['month'] == season['start_month']) &
(df['day'] < season['start_day']))
df.drop(df[before_start].index, inplace=True)
df = df.loc[~before_start]

after_end = ((df['month'] == season['end_month']) &
(df['day'] > season['end_day']))
df.drop(df[after_end].index, inplace=True)
df = df.loc[~after_end]

return df


def calculate_percentile(df: pd.DataFrame, percentile: float) -> dict:
Expand Down

0 comments on commit e62c64f

Please sign in to comment.