Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
guipsamora
GitHub Repository: guipsamora/pandas_exercises
Path: blob/master/10_Deleting/Iris/Solutions.ipynb
613 views
Kernel: Python 2

Iris

Introduction:

This exercise may seem a little bit strange, but keep doing it.

Step 1. Import the necessary libraries

import pandas as pd import numpy as np

Step 2. Import the dataset from this address.

Step 3. Assign it to a variable called iris

Step 4. Create columns for the dataset

# 1. sepal_length (in cm) # 2. sepal_width (in cm) # 3. petal_length (in cm) # 4. petal_width (in cm) # 5. class

Step 5. Is there any missing value in the dataframe?

sepal_length 0 sepal_width 0 petal_length 0 petal_width 0 class 0 dtype: int64

Step 6. Lets set the values of the rows 10 to 29 of the column 'petal_length' to NaN

Step 7. Good, now lets substitute the NaN values to 1.0

Step 8. Now let's delete the column class

Step 9. Set the first 3 rows as NaN

Step 10. Delete the rows that have NaN

Step 11. Reset the index so it begins with 0 again

BONUS: Create your own question and answer it.