Skip to content

Commit

Permalink
Upgrade Pandas to v2 (bcgov#3260)
Browse files Browse the repository at this point in the history
Upgrades pandas to v2
  • Loading branch information
brettedw authored Nov 23, 2023
1 parent b9d6b3c commit 7035d4f
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 7035d4f

Please sign in to comment.