import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.read_csv('cars.csv')
# Desviación estandar
df['price_usd'].std()
# Rango = valor max - valor min
rango = df['price_usd'].max() - df['price_usd'].min()
rango
# Quartiles
median = df['price_usd'].median()
print(f'Media: {median}')
Q1 = df['price_usd'].quantile(q=0.25)
print(f'Q1: {Q1}')
Q3 = df['price_usd'].quantile(q=0.75)
print(f'Q3: {Q3}')
# Los cuartiles y percentiles son casos especificos de uso del Quantil
min_val = df['price_usd'].quantile(q=0)
print(f'Valor minimo: {min_val}')
max_val = df['price_usd'].quantile(q=1.0)
print(f'Valor maximo: {max_val}')
iqr = Q3 - Q1
print(f"Rango Intercuartil: {iqr}")
minlimit = Q1 - 1.5*iqr
maxlimit = Q3 + 1.5*iqr
print('rango para detección de outliers: {}, {}'.format(minlimit, maxlimit))
sns.set(rc={'figure.figsize':(11.7,8.27)})
# f, (ax_hist, ax_box) = plt.subplots(2, sharex=True, gridspec_kw={"height_ratios": (.6, .4)})
sns.histplot(df['price_usd'])
sns.boxplot(df['price_usd'])
sns.boxplot(x = 'engine_fuel', y= 'price_usd', data=df)
sns.set(rc={'figure.figsize':(11.7,8.27)})
f, (ax_hist, ax_box) = plt.subplots(2, sharex=True, gridspec_kw={"height_ratios": (.6, .4)})
sns.histplot(df['price_usd'], ax=ax_hist)
sns.boxplot(df['price_usd'], ax=ax_box)
ax_hist.set(xlabel='')
sns.boxplot(x = 'engine_fuel', y = 'price_usd', data = df)