Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
guipsamora
GitHub Repository: guipsamora/pandas_exercises
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

Step 2. Import the dataset from this address.

Step 3. Assign it to a variable called wine

Step 4. Delete the first, fourth, seventh, nineth, eleventh, thirteenth and fourteenth columns

Step 5. Assign the columns as below:

The attributes are (donated by Riccardo Leardi, riclea '@' anchem.unige.it):

  1. alcohol

  2. malic_acid

  3. alcalinity_of_ash

  4. magnesium

  5. flavanoids

  6. proanthocyanins

  7. hue

Step 6. Set the values of the first 3 rows from alcohol as NaN

Step 7. Now set the value of the rows 3 and 4 of magnesium as NaN

Step 8. Fill the value of NaN with the number 10 in alcohol and 100 in magnesium

Step 9. Count the number of missing values

Step 10. Create an array of 10 random numbers up until 10

Step 11. Use random numbers you generated as an index and assign NaN value to each of cell.

Step 12. How many missing values do we have?

Step 13. Delete the rows that contain missing values

Step 14. Print only the non-null values in alcohol

Step 15. Reset the index, so it starts with 0 again

BONUS: Create your own question and answer it.