Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Transformation Grid | Data Transformation Techniques
Data Preprocessing and Feature Engineering

bookChallenge: Transformation Grid

Task

Swipe to start coding

You are given the Titanic dataset from the seaborn library. Your goal is to perform data transformation using pandas and scikit-learn.

Perform the following steps:

  1. Load the dataset with sns.load_dataset("titanic").
  2. Fill missing values in age and embarked (mean and mode).
  3. Encode the categorical columns sex and embarked using pd.get_dummies() (drop the first category to avoid redundancy).
  4. Scale the numeric columns age and fare using StandardScaler.
  5. Create a new column family_size = sibsp + parch + 1.
  6. Return the transformed dataset as transformed_data.

Print .head() to preview the result.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 4
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

Can you explain that in simpler terms?

What are some examples related to this topic?

How does this information apply to real-world situations?

close

Awesome!

Completion rate improved to 8.33

bookChallenge: Transformation Grid

Swipe to show menu

Task

Swipe to start coding

You are given the Titanic dataset from the seaborn library. Your goal is to perform data transformation using pandas and scikit-learn.

Perform the following steps:

  1. Load the dataset with sns.load_dataset("titanic").
  2. Fill missing values in age and embarked (mean and mode).
  3. Encode the categorical columns sex and embarked using pd.get_dummies() (drop the first category to avoid redundancy).
  4. Scale the numeric columns age and fare using StandardScaler.
  5. Create a new column family_size = sibsp + parch + 1.
  6. Return the transformed dataset as transformed_data.

Print .head() to preview the result.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 4
single

single

some-alt