Streamlit_code / utils /feature_engineering.py
Junaid-EEE11's picture
Create utils/feature_engineering.py
ca879f8
raw
history blame contribute delete
444 Bytes
# 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