How to split feature under Feature engineering?

Splitting feature

Most of the time the dataset contains complex features i.e combination of two or more features. By extracting and creating more meaningful features can improve model performance by uncovering potential information.

It can be applied to both continuous and categorical features.

For example: Given that in the housing price dataset there is a feature ‘floors’ whose values are in float and integer part represents the number of floors and 0.5 decimal part indicates if there it is a penthouse or not.

import pandas as pd

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

# Separating integer part and fractional part to create two new features
df['floor_num'] = df['floors'].apply(lambda x:x//1)
df['Is_penrhouse'] = df['floors'].apply(lambda x:x%1)