<jupyter_start><jupyter_text>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<jupyter_code>import pandas as pd
import numpy as np<jupyter_output><empty_output><jupyter_text>Step 2. Import the dataset from this [address](https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data).   Step 3. Assign it to a variable called wine<jupyter_code>wine = pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data')
wine.head()<jupyter_output><empty_output><jupyter_text>Step 4. Delete the first, fourth, seventh, nineth, eleventh, thirteenth and fourteenth columns<jupyter_code>wine = wine.drop(wine.columns[[0, 3, 6,8,10,12,13]], axis=1)
wine.head()<jupyter_output><empty_output><jupyter_text>Step 5. Assign the columns as below:The attributes are (dontated by <NAME>, riclea '@' anchem.unige.it):  1) alcohol  2) malic_acid  3) alcalinity_of_ash  4) magnesium  5) flavanoids  6) proanthocyanins  7) hue<jupyter_code>wine.columns = ['alcohol', 'malic_acid', 'alcalinity_of_ash', 'magnesium', 'flavanoids', 'proanthocyanins', 'hue']
wine<jupyter_output><empty_output><jupyter_text>Step 6. Set the values of the first 3 rows from alcohol as NaN<jupyter_code>wine.alcohol.iloc[:3] = np.nan
wine.head(3)<jupyter_output><empty_output><jupyter_text>Step 7. Now set the value of the rows 3 and 4 of magnesium as NaN<jupyter_code>wine.magnesium.iloc[3:5] = np.nan
wine.head(6)<jupyter_output><empty_output><jupyter_text>Step 8. Fill the value of NaN with the number 10 in alcohol and 100 in magnesium<jupyter_code>wine.alcohol = wine.alcohol.fillna(10)
wine.magnesium = wine.magnesium.fillna(100)
wine.head(10)<jupyter_output><empty_output><jupyter_text>Step 9. Count the number of missing values<jupyter_code>wine.isna().sum()<jupyter_output><empty_output><jupyter_text>Step 10.  Create an array of 10 random numbers up until 10<jupyter_code>rnd = np.random.randint(10,size=10)<jupyter_output><empty_output><jupyter_text>Step 11.  Use random numbers you generated as an index and assign NaN value to each of cell.<jupyter_code>wine.alcohol[rnd] = np.nan
wine.head(10)<jupyter_output><empty_output><jupyter_text>Step 12.  How many missing values do we have?<jupyter_code>wine.alcohol.isnull().sum()<jupyter_output><empty_output><jupyter_text>Step 13. Delete the rows that contain missing values<jupyter_code>wine = wine.dropna()<jupyter_output><empty_output><jupyter_text>Step 14. Print only the non-null values in alcohol<jupyter_code>wine.alcohol[~wine.alcohol.isnull()]<jupyter_output><empty_output><jupyter_text>Step 15.  Reset the index, so it starts with 0 again<jupyter_code>wine = wine.reset_index(drop=True)
wine<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11567297393787933, 'fraction_numerical': 0.024991074616208496, 'mean_word_length': 7.289940828402367, 'pattern_counts': {'":': 0, '<': 58, '<?xml version=': 0, '>': 58, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '14', 'dir': 'jupyter-structured-clean-dedup', 'id': '310791', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1001, 'n_words': 230, 'path': '10_Deleting/Wine/Exercises.ipynb', 'repo_name': 'fung991159/pandas_exercise', 'size': '2810'}