Challenge: Transformation Grid
Oppgave
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
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 8
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Fantastisk!
Completion rate forbedret til 8.33
Challenge: Transformation Grid
Sveip for å vise menyen
Oppgave
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
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 8
single