<jupyter_start><jupyter_text>Ex1 - Filtering and Sorting Data This time we are going to pull data directly from the internet.Special thanks to: https://github.com/justmarkham for sharing the dataset and materials. Step 1. Import the necessary libraries<jupyter_code>import pandas as pd<jupyter_output><empty_output><jupyter_text>Step 2. Import the dataset from this [address](https://raw.githubusercontent.com/justmarkham/DAT8/master/data/chipotle.tsv).   Step 3. Assign it to a variable called chipo.<jupyter_code>chipo = pd.read_csv("https://raw.githubusercontent.com/justmarkham/DAT8/master/data/chipotle.tsv", sep="\t")<jupyter_output><empty_output><jupyter_text>Step 4. How many products cost more than $10.00?<jupyter_code># clean the item_price column and transform it in a float
#prices = [float(value[1 : -1]) for value in chipo.item_price]
#chipo.item_price = prices

chipo_filtered = chipo.drop_duplicates(["item_name", "quantity", "choice_description"])

chipo_filtered = chipo_filtered[chipo_filtered.quantity == 1]


chipo.query('item_price > 10').item_name.nunique()<jupyter_output><empty_output><jupyter_text>Step 5. What is the price of each item?  print a data frame with only two columns item_name and item_price<jupyter_code># delete the duplicates in item_name and quantity
chipo_filtered = chipo.drop_duplicates(["item_name", "quantity"])

# select only the products with quantity equals to 1
chipo_one_product = chipo_filtered[chipo_filtered.quantity == 1]

# select only the item_name and item_price columns
chipo_prices = chipo_filtered[["item_name", "item_price"]]

# sort the values from the most to less expensive
chipo_prices.sort_values(by="item_price", ascending=False).head(20)<jupyter_output><empty_output><jupyter_text>Step 6. Sort by the name of the item<jupyter_code>chipo_prices.sort_values(by="item_name")<jupyter_output><empty_output><jupyter_text>Step 7. What was the quantity of the most expensive item ordered?<jupyter_code>chipo.head()
chipo.sort_values(by="item_price", ascending=False).head(1)<jupyter_output><empty_output><jupyter_text>Step 8. How many times was a Veggie Salad Bowl ordered?<jupyter_code>salad = chipo[chipo.item_name=="Veggie Salad Bowl"]
len(salad)<jupyter_output><empty_output><jupyter_text>Step 9. How many times did someone order more than one Canned Soda?<jupyter_code>soda = chipo[(chipo.item_name == "Canned Soda") & (chipo.quantity > 1)]
soda.shape[0]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10803098247044435, 'fraction_numerical': 0.01141459437423563, 'mean_word_length': 7.29054054054054, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 35, 'https://': 3, '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': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '521726', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 870, 'n_tokens_neox': 824, 'n_words': 204, 'path': '02_Filtering_&_Sorting/Chipotle/Exercises.ipynb', 'repo_name': 'dmnkfr/pandas_exercises', 'size': '2453'}