diff --git a/fraud_batch/features/transactions_fraud.py b/fraud_batch/features/transactions_fraud.py index a94d82f6..cfd1f608 100644 --- a/fraud_batch/features/transactions_fraud.py +++ b/fraud_batch/features/transactions_fraud.py @@ -15,7 +15,7 @@ def get_age_at_transaction(trans_df: pd.DataFrame, profiles_df: pd.DataFrame) -> """ # Compute age at transaction. age_df = trans_df.merge(profiles_df, on="cc_num", how="left") - trans_df["age_at_transaction"] = (age_df["datetime"] - age_df["birthdate"]) / np.timedelta64(1, "Y") + trans_df["age_at_transaction"] = (age_df["datetime"] - age_df["birthdate"]) / np.timedelta64(365, "D") return trans_df diff --git a/integrations/great_expectations/fraud_batch_data_validation.ipynb b/integrations/great_expectations/fraud_batch_data_validation.ipynb index f5918e29..01fd7a04 100644 --- a/integrations/great_expectations/fraud_batch_data_validation.ipynb +++ b/integrations/great_expectations/fraud_batch_data_validation.ipynb @@ -137,7 +137,7 @@ "\n", "# Compute age at transaction.\n", "age_df = trans_df.merge(profiles_df, on=\"cc_num\", how=\"left\")\n", - "trans_df[\"age_at_transaction\"] = (age_df[\"datetime\"] - age_df[\"birthdate\"]) / np.timedelta64(1, \"Y\")\n", + "trans_df[\"age_at_transaction\"] = (age_df[\"datetime\"] - age_df[\"birthdate\"]) / np.timedelta64(365, \"D\")\n", "\n", "# Convert date time object to unix epoch in milliseconds\n", "trans_df.datetime = trans_df.datetime.values.astype(np.int64) // 10 ** 6" diff --git a/integrations/monitoring/feature_statistics_monitoring.ipynb b/integrations/monitoring/feature_statistics_monitoring.ipynb index 209d14ef..f309006f 100755 --- a/integrations/monitoring/feature_statistics_monitoring.ipynb +++ b/integrations/monitoring/feature_statistics_monitoring.ipynb @@ -119,7 +119,7 @@ "age_df = trans_df_raw.merge(profiles_df, on=\"cc_num\", how=\"left\")\n", "trans_df_raw[\"age_at_transaction\"] = (\n", " age_df[\"datetime\"] - age_df[\"birthdate\"]\n", - ") / np.timedelta64(1, \"Y\")\n", + ") / np.timedelta64(365, \"D\")\n", "\n", "card_expiry_df = trans_df_raw.merge(credit_cards_df, on=\"cc_num\", how=\"left\")\n", "card_expiry_df[\"expires\"] = pd.to_datetime(\n", diff --git a/integrations/wandb/1_feature_groups.ipynb b/integrations/wandb/1_feature_groups.ipynb index d67e9c9f..f2f9f4d8 100755 --- a/integrations/wandb/1_feature_groups.ipynb +++ b/integrations/wandb/1_feature_groups.ipynb @@ -121,7 +121,7 @@ "\n", "# Compute age at transaction.\n", "age_df = trans_df.merge(profiles_df, on=\"cc_num\", how=\"left\")\n", - "trans_df[\"age_at_transaction\"] = (age_df[\"datetime\"] - age_df[\"birthdate\"]) / np.timedelta64(1, \"Y\")\n", + "trans_df[\"age_at_transaction\"] = (age_df[\"datetime\"] - age_df[\"birthdate\"]) / np.timedelta64(365, \"D\")\n", "\n", "# Compute days until card expires.\n", "card_expiry_df = trans_df.merge(credit_cards_df, on=\"cc_num\", how=\"left\")\n", diff --git a/quickstart.ipynb b/quickstart.ipynb index d9cb9546..20632d9b 100644 --- a/quickstart.ipynb +++ b/quickstart.ipynb @@ -156,7 +156,7 @@ "age_df = trans_df.merge(profiles_df, on=\"cc_num\", how=\"left\")\n", "\n", "# Compute the age at the time of each transaction and store it in the 'age_at_transaction' column\n", - "trans_df[\"age_at_transaction\"] = (age_df[\"datetime\"] - age_df[\"birthdate\"]) / np.timedelta64(1, \"Y\")\n", + "trans_df[\"age_at_transaction\"] = (age_df[\"datetime\"] - age_df[\"birthdate\"]) / np.timedelta64(365, \"D\")\n", "\n", "# Merge the 'trans_df' DataFrame with the 'credit_cards_df' DataFrame based on the 'cc_num' column\n", "card_expiry_df = trans_df.merge(credit_cards_df, on=\"cc_num\", how=\"left\")\n",