Skip to content
CampusEduX

Problem 1: Create an Interaction Feature

Easypython
Learn the Concept: Feature Engineering

Problem Description

Write a Python program that creates a new interaction feature by multiplying two existing numeric columns ("bedrooms" and "bathrooms") in a DataFrame.

Input

A DataFrame with "bedrooms" and "bathrooms" columns.

Output

The DataFrame with a new "bedbathinteraction" column.

Constraints

  • None specific.

Example Input

text
{"bedrooms": [2,3,4], "bathrooms": [1,2,3]}

Example Output

text
bedrooms bathrooms bed_bath_interaction 0 2 1 2 1 3 2 6 2 4 3 12

Concepts Covered

Column multiplication, new feature creation.

Related Problems

  • Problem 2: Extract Features from a Date Column
    Easy · python
    Solve Problem
  • Problem 3: Generate Polynomial Features
    Easy · python
    Solve Problem
  • Problem 4: Bin a Continuous Feature into Categories
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...