<jupyter_start><jupyter_text>Getting and Knowing your Dataimport dataset from https://raw.githubusercontent.com/justmarkham/DAT8/master/data/chipotle.tsv<jupyter_code>import numpy as np
import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/justmarkham/DAT8/master/data/chipotle.tsv", sep = '\t')<jupyter_output><empty_output><jupyter_text>See the first 10 entries<jupyter_code>df.head(10)<jupyter_output><empty_output><jupyter_text>The number of observations in the dataset<jupyter_code>df.shape[0]
df.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 4622 entries, 0 to 4621
Data columns (total 5 columns):
order_id              4622 non-null int64
quantity              4622 non-null int64
item_name             4622 non-null object
choice_description    3376 non-null object
item_price            4622 non-null object
dtypes: int64(2), object(3)
memory usage: 180.7+ KB<jupyter_text>The number of columns in the dataset<jupyter_code>df.shape[1]
df.columns<jupyter_output><empty_output><jupyter_text>Dataset index<jupyter_code>df.index<jupyter_output><empty_output><jupyter_text>The most-ordered item<jupyter_code>items = df.groupby("item_name")
items = items.sum()
items = items.sort_values(["quantity"], ascending = False)
items.head()
items.head(1)<jupyter_output><empty_output><jupyter_text>The most ordered item in the choice_description column<jupyter_code>choice_des = df.groupby("choice_description").sum()
choice_des = choice_des.sort_values(["quantity"], ascending = False)
choice_des.head()<jupyter_output><empty_output><jupyter_text>The number of items was orderd in total<jupyter_code>df.quantity.sum()<jupyter_output><empty_output><jupyter_text>Turn the item price into a float<jupyter_code>df.item_price.dtype
func = lambda x: float(x[1:-1])
df.item_price = df.item_price.apply(func)
df.item_price.dtype<jupyter_output><empty_output><jupyter_text>The revenue for the period in the dataset<jupyter_code>revenue = ((df.quantity)*(df.item_price)).sum()
revenue<jupyter_output><empty_output><jupyter_text>The orders were made in the period<jupyter_code>order = df.order_id.value_counts().count()
order<jupyter_output><empty_output><jupyter_text>The average revenue amount per order<jupyter_code>df["revenue"] = (df.quantity)*(df.item_price)
order_group = df.groupby(by=["order_id"]).sum()
order_group.mean()["revenue"]
df.groupby(by=["order_id"]).sum().mean()["revenue"]<jupyter_output><empty_output><jupyter_text>The different items are sold<jupyter_code>df.item_name.value_counts().count()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12626262626262627, 'fraction_numerical': 0.020590520590520592, 'mean_word_length': 7.78839590443686, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, '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': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '341201', 'license': 'MIT', 'n_tokens_mistral': 961, 'n_tokens_neox': 918, 'n_words': 152, 'path': 'DataTalks_GettingKnowingData II.ipynb', 'repo_name': 'gympohnpimol/Pandas-Data-Talks', 'size': '2574'}