Skip to content

Commit

Permalink
[FSTORE-1055] Pandas 2.1.x compatibility (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
robzor92 authored Jan 2, 2024
1 parent 41daef3 commit 3d4dd4b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion fraud_batch/features/transactions_fraud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion integrations/wandb/1_feature_groups.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 3d4dd4b

Please sign in to comment.