<jupyter_start><jupyter_text>Wine Recommendation Analizing the database of wine reviews: [Wine Reviews](https://www.kaggle.com/zynicide/wine-reviews) inspired by [wine-recommender](https://www.kaggle.com/sudhirnl7/wine-recommender/notebook)  Import and read csv<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

%matplotlib inline
plt.style.use('fivethirtyeight')
plt.rcParams.update({'font.size':12})
path = 'input/'
path_150k = path + 'winemag-data_first150k.csv'
path_130k = path + 'winemag-data-130k-v2.csv'

wine_150k = pd.read_csv(path_150k)
wine_130k = pd.read_csv(path_130k)
print(wine_150k.shape)
print(wine_130k.shape)<jupyter_output>(150930, 11)
(129971, 14)<jupyter_text>Data Cleaning and Analyzing Data The wine_130k has more columns than wine_150k, but I don't see any problem to concatenate<jupyter_code>list(set(wine_130k.columns) - set( wine_150k.columns))
wines = pd.concat([wine_130k, wine_150k], axis=0)
wines.rename(columns = {'Unnamed: 0': 'Index_P'}, inplace = True)
wines.head()
wines.describe(include='all',).T
wines.dtypes<jupyter_output><empty_output><jupyter_text>Handling Missing Values<jupyter_code>missing_val_count_by_column = (wines.isnull().sum())
print(missing_val_count_by_column[missing_val_count_by_column > 0].sort_values(ascending=False))
percent_missing = ((wines.isnull().sum().sum())/np.product(wines.shape)*100)
print(percent_missing)<jupyter_output>21.156894625305203<jupyter_text>For me it doesn't make sense to deal with priceless neighbors, excludes the empty values of provincial parents and variety for being too small to deal<jupyter_code>wines.shape
wines.dropna(subset=['price','country', 'province', 'variety'], inplace=True)
wines.shape
missing_val_count_by_column = (wines.isnull().sum())
print(missing_val_count_by_column[missing_val_count_by_column > 0].sort_values(ascending=False))<jupyter_output>taster_twitter_handle    166645
taster_name              161725
region_2                 147149
title                    137230
designation               77078
region_1                  42352
dtype: int64<jupyter_text>Distribution of Wine Reviews by Top 10 Countries<jupyter_code>#print('Number of country list in data:',wine['country'].nunique())
plt.figure(figsize=(14,10))
cnt = wine['country'].value_counts().to_frame()[0:10]
sns.barplot(x= cnt['country'], y =cnt.index, data=cnt, palette='Set2',orient='h')
plt.title('Distribution of Wine Reviews by Top 10 Countrie');<jupyter_output><empty_output><jupyter_text>Distribution of wine price<jupyter_code>sns.displot(data = wines,color='r', x="price", kind="ecdf", height=8)
plt.title('Distribution of price')
plt.figure(figsize=(14,10))
sns.boxplot(data=wines, x='price')
plt.title('Boxplot of price')
mean_price = 34.179725
std_price = 38.615971
wines['price'].describe()
good_price = mean_price + 2*std_price
good_price
sns.displot(data = wines[wines['price']<good_price],color='b', x="price", kde=True, height=8)
plt.title('Distribution of price even the good price')
plt.figure(figsize=(14,10))
sns.boxplot(data=wines[wines['price']<111], x='price')
plt.title('Boxplot of price even the good price')
sns.displot(data = wines[wines['price']<good_price],color='r', x="price", y="points", kind="kde", rug=True, height=8)
plt.title('Distribution of price and points even the good price')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13770685579196218, 'fraction_numerical': 0.051122931442080376, 'mean_word_length': 7.002364066193853, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 24, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '479978', 'license': 'MIT', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1199, 'n_words': 234, 'path': '.ipynb_checkpoints/Wine-Recommendation-checkpoint.ipynb', 'repo_name': 'FelipeEnne/Wine-Recommendation', 'size': '3384'}