How to create a new feature by combining the multiple feature in feature engineering?

Creating a new feature by combining multiple features

In this type of feature engineering technique, we create new features by combining two or more features which can give us more insights.

For example, We have a stroke prediction dataset where we need to predict if a person will have a stroke or not.

Feature Engineering

Here we can see and also can confirm by EDA that people with higher age have more chances of stroke, similarly person with a higher BMI and avg_gulcose_level is more likely to have a stroke.

We can create new features like if person age > 50 and avg_gulcode_level > 180 then populate 1

Also, we can create features if a person is having hypertension and heart disease then create another feature for that.

import pandas as pd

#reading file
df = pd.read_csv('stroke_prediction.csv')

# creating new feature with person having hypertension and heart_disease
a = (df["hypertension"]=="1")
df['hypertension_heart_patient'] = a&b
df = df.replace(True, 1)
df = df.replace(False, 0)