text_html_output_1.png
from scipy import stats

from sklearn.preprocessing import LabelEncoder

from sklearn.preprocessing import OneHotEncoder

import matplotlib.pyplot as plt #biblioteca para criar gráficos "comuns" ao estilo Matplot

import numpy as np #biblioteca utilizada para trabalhar com vetores

import pandas as pd #biblioteca para trabalhar com dataframes (planilhas excel)

import seaborn as sns #biblioteca utilizada para cirar gráficos mais "bonitos"

customers = pd.read_csv('../input/customer-segmentation-tutorial-in-python/Mall_Customers.csv')

customers.isnull().sum()

customers_null = customers
for col in customers_null.columns:
    customers_null.loc[customers_null.sample(frac=0.1).index, col] = np.nan

boxplot = customers.boxplot(column=['Age', 'Annual Income (k$)', 'Spending Score (1-100)']) 
#constroi o boxplot para as colunas desejadas

from scipy import stats
z = np.abs(stats.zscore(customers['Annual Income (k$)'].values))
thereshold = 2
result = np.where(z > thereshold)
df_salario_outlier = customers.iloc[result[0]]

cat_df_customers = customers.select_dtypes(include=['object'])

cat_df_customers_replace = pd.read_csv('../input/customer-segmentation-tutorial-in-python/Mall_Customers.csv')

customers = pd.read_csv('../input/customer-segmentation-tutorial-in-python/Mall_Customers.csv')

cat_df_customers_lc = customers

cat_df_customers_lc['Gender'] = pd.Categorical(cat_df_customers_lc['Gender'])
cat_df_customers_lc.dtypes

from sklearn.preprocessing import LabelEncoder
le = LabelEncoder()

customers_label = pd.read_csv('../input/customer-segmentation-tutorial-in-python/Mall_Customers.csv')
customers_label['Gender'] = le.fit_transform(customers_label['Gender'])

customers_one_hot = pd.read_csv('../input/customer-segmentation-tutorial-in-python/Mall_Customers.csv')
customers_one_hot = pd.get_dummies(customers_one_hot)

customers = pd.read_csv('../input/customer-segmentation-tutorial-in-python/Mall_Customers.csv')

customers_one_hot = customers
from sklearn.preprocessing import OneHotEncoder
ohe = OneHotEncoder()

customers_ohe = ohe.fit_transform(customers_one_hot['Gender'].values.reshape(-1, 1)).toarray()
customers_ohe.shape