Challenge: Transformation Grid
Uppgift
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:
- Load the dataset with
sns.load_dataset("titanic"). - Fill missing values in
ageandembarked(mean and mode). - Encode the categorical columns
sexandembarkedusingpd.get_dummies()(drop the first category to avoid redundancy). - Scale the numeric columns
ageandfareusingStandardScaler. - Create a new column
family_size = sibsp + parch + 1. - Return the transformed dataset as
transformed_data.
Print .head() to preview the result.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 1. Kapitel 8
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Fantastiskt!
Completion betyg förbättrat till 8.33
Challenge: Transformation Grid
Svep för att visa menyn
Uppgift
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:
- Load the dataset with
sns.load_dataset("titanic"). - Fill missing values in
ageandembarked(mean and mode). - Encode the categorical columns
sexandembarkedusingpd.get_dummies()(drop the first category to avoid redundancy). - Scale the numeric columns
ageandfareusingStandardScaler. - Create a new column
family_size = sibsp + parch + 1. - Return the transformed dataset as
transformed_data.
Print .head() to preview the result.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 1. Kapitel 8
single