Skip to content

Commit

Permalink
Merge pull request #154 from aidh-ms/issue/fix-warnings
Browse files Browse the repository at this point in the history
Fix warnings
  • Loading branch information
Paul-B98 authored Feb 3, 2025
2 parents 9c57d68 + aa26b59 commit 86f68ac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pyaki/preprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def process(self, df: pd.DataFrame) -> pd.DataFrame:
The processed urine output dataset as a pandas DataFrame.
"""

df = df.groupby(self._stay_identifier).resample("1H").sum() # type: ignore
df = df.groupby(self._stay_identifier).resample("1h").sum() # type: ignore
df[df["urineoutput"] == 0] = None

if not self._interpolate:
Expand Down Expand Up @@ -195,7 +195,7 @@ def process(self, df: pd.DataFrame) -> pd.DataFrame:
pd.DataFrame
The processed creatinine dataset as a pandas DataFrame.
"""
df = df.groupby(self._stay_identifier).resample("1H").mean() # type: ignore
df = df.groupby(self._stay_identifier).resample("1h").mean() # type: ignore
if not self._ffill:
return df

Expand Down Expand Up @@ -244,5 +244,5 @@ def process(self, df: pd.DataFrame) -> pd.DataFrame:
pd.DataFrame
The processed RRT dataset as a pandas DataFrame.
"""
df = df.groupby(self._stay_identifier).resample("1H").last() # type: ignore
df = df.groupby(self._stay_identifier).resample("1h").last() # type: ignore
return df.ffill()
12 changes: 12 additions & 0 deletions pyaki/probes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import numpy as np
import pandas as pd
from pandas import PeriodIndex

from pyaki.utils import Dataset, DatasetType, approx_gte, dataset_as_df, df_to_dataset

Expand Down Expand Up @@ -164,6 +165,8 @@ def probe(
if self._patient_weight_column not in patient:
raise ValueError("Missing weight for stay")

df = df.copy()

weight: pd.Series = patient[self._patient_weight_column]
# fmt: off
df.loc[:, self.RESNAME] = np.nan # set all urineoutput_stage values to NaN
Expand Down Expand Up @@ -316,6 +319,9 @@ def creatinine_baseline(self, df: pd.DataFrame, patient: pd.DataFrame) -> pd.Ser
pd.Series
The calculated creatinine baseline values.
"""
if isinstance(df.index, PeriodIndex):
df.index = df.index.to_timestamp()

if self._method == CreatinineBaselineMethod.ROLLING_FIRST:
return (
df[df[self._column] > 0]
Expand Down Expand Up @@ -547,6 +553,8 @@ def probe(
pd.DataFrame
The modified DataFrame with the absolute creatinine stage column added.
"""
df = df.copy()

baseline_values: pd.Series = self.creatinine_baseline(df, patient)

df.loc[:, self.RESNAME] = 0
Expand Down Expand Up @@ -623,6 +631,8 @@ def probe(self, df: pd.DataFrame, patient: pd.DataFrame, **kwargs: Any) -> pd.Da
pd.DataFrame
The modified DataFrame with the relative creatinine stage column added.
"""
df = df.copy()

baseline_values: pd.Series = self.creatinine_baseline(df, patient)

df.loc[:, self.RESNAME] = 0
Expand Down Expand Up @@ -676,6 +686,8 @@ def probe(self, df: pd.DataFrame) -> pd.DataFrame:
pd.DataFrame
The modified DataFrame with the RRT stage column added.
"""
df = df.copy()

df.loc[:, self.RESNAME] = 0
df.loc[df[self._column] == 1, self.RESNAME] = 3

Expand Down

0 comments on commit 86f68ac

Please sign in to comment.