Spaces:
Sleeping
Sleeping
File size: 444 Bytes
ca879f8 |
1 2 3 4 5 6 7 8 9 10 11 12 |
# utils/feature_engineering.py
import pandas as pd
import numpy as np
def feature_engineering(df):
df['hour_of_day'] = pd.to_datetime(df['timestamp']).dt.hour
df['day_of_week'] = pd.to_datetime(df['timestamp']).dt.dayofweek
df['amount_times_hour'] = df['amount'] * df['hour_of_day']
df['log_amount'] = df['amount'].apply(lambda x: 0 if x == 0 else np.log(x + 1))
df = df.drop(['timestamp', 'amount'], axis=1)
return df
|