<jupyter_start><jupyter_text>Cocktail Data Analysis  Import Raw Data Set<jupyter_code>import pandas as pd
raw_data = pd.read_csv("Cocktail_Data.csv")<jupyter_output><empty_output><jupyter_text>Data Type Change Our list data are saved into string data. We should convert this back... Should have saved this into pickle<jupyter_code>type(raw_data["Nu Mai Tai"][0])
from ast import literal_eval
raw_data = raw_data.transpose().iloc[1:,]
raw_data.columns = ["base","flavor","type","strength","ingredients"]
def converter(df,l):
    """convert string type data to list
    
    
    arguments:
    
    # pd.DataFrame
    df -- dataframe of the column
    
    # string
    l  -- name of column; a list of strings that you want to convert to a list of lists
    
    
    example:
    converter(df, ["['hello']" , "['hi','bye']", "['what']"])
    
    result: 
    returns dataframe with modified column
    
    ex)[In ]:     df[l] 
       [Out ]:   [["hello"], ["hi","bye"] , ["what"]]
    
    """
    list_of_strings = df[l].tolist()
    df[l] = [literal_eval(x) for x in list_of_strings]
    
    return df
for column in ["base","flavor","ingredients"]:
    converter(raw_data,column)<jupyter_output><empty_output><jupyter_text>Check the conversion<jupyter_code>type(raw_data.loc["Nu Mai Tai"][0])
raw_data = raw_data.transpose()
raw_data
pd.to_pickle(raw_data, "./cocktail_pickle")
df = pd.read_pickle("cocktail_pickle")<jupyter_output><empty_output><jupyter_text>Exploratory Data Analysis (EDA)  Descriptive Statistics<jupyter_code>df.T.describe()<jupyter_output><empty_output><jupyter_text>Flavor distribution, statistics<jupyter_code>df = df.T
all_flavs = []
for x in df["flavor"].tolist():
    all_flavs += x
print("There are total {} of flavors".format(len(set(all_flavs))))
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
plt.figure(figsize=(20,10))
plt.title("Flavors")
sns.countplot(all_flavs)<jupyter_output><empty_output><jupyter_text>Base Spirit<jupyter_code>base_spirit = []

for x in df["base"].tolist():
    base_spirit += x
print("There are total {} of base spirits".format(len(set(all_flavs))))

plt.figure(figsize=(50,30))
plt.title("Base Spirits")
sns.countplot(base_spirit)<jupyter_output>There are total 12 of base spirits<jupyter_text>Ingredients<jupyter_code>all_ingredient = []
for recipe in df["ingredients"].tolist():
    for ingredient in recipe:
        all_ingredient.append(ingredient.split("@")[-1].strip())

all_ingredient = list(set(all_ingredient))
print(len(all_ingredient))
sorted(all_ingredient)
""" 
 'Coco Lopez coconut cream',
 'Coco Lopez cream of coconut'

 'Coconut milk',
 'Coconut milk (full fat)

 'Coffee bitters',
 'Coffee bitters*

 'Concord grape and jasmine syrup*',
 'Concord grape mint syrup*',
 'Concord grape puree*',
 'Concord grape rosemary syrup*',
 'Concord grape shrub*',
 'Concord grape syrup*',
 'Concord grapes'
 
 
 'Club soda',
 'Club soda or Champagne',
 'Club soda, chilled',
 'Club soda, divided',
 'Club soda, to fill',
 """<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1410761154855643, 'fraction_numerical': 0.004593175853018373, 'mean_word_length': 5.098, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 0, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '341266', 'license': 'MIT', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1075, 'n_words': 249, 'path': 'working/cocktail_data_analysis.ipynb', 'repo_name': 'agdal1125/cocktail4u', 'size': '3048'}