Path: blob/master/10_Deleting/Wine/Exercises.ipynb
613 views
Kernel: Python [default]
Wine
Introduction:
This exercise is a adaptation from the UCI Wine dataset. The only pupose is to practice deleting data with pandas.
Step 1. Import the necessary libraries
In [ ]:
Step 2. Import the dataset from this address.
Step 3. Assign it to a variable called wine
In [ ]:
Step 4. Delete the first, fourth, seventh, nineth, eleventh, thirteenth and fourteenth columns
In [ ]:
Step 5. Assign the columns as below:
The attributes are (donated by Riccardo Leardi, riclea '@' anchem.unige.it):
alcohol
malic_acid
alcalinity_of_ash
magnesium
flavanoids
proanthocyanins
hue
In [ ]:
Step 6. Set the values of the first 3 rows from alcohol as NaN
In [ ]:
Step 7. Now set the value of the rows 3 and 4 of magnesium as NaN
In [ ]:
Step 8. Fill the value of NaN with the number 10 in alcohol and 100 in magnesium
In [ ]:
Step 9. Count the number of missing values
In [ ]:
Step 10. Create an array of 10 random numbers up until 10
In [ ]:
Step 11. Use random numbers you generated as an index and assign NaN value to each of cell.
In [ ]:
Step 12. How many missing values do we have?
In [ ]:
Step 13. Delete the rows that contain missing values
In [ ]:
Step 14. Print only the non-null values in alcohol
In [ ]:
In [ ]:
Step 15. Reset the index, so it starts with 0 again
In [ ]:
BONUS: Create your own question and answer it.
In [ ]: