Análisis de los 25 retailers más grandes de Estados Unidos DataAcademy 2022 Platzi.
# Importar librerías aquí
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
# Importar datos aquí
df=pd.read_csv('/work/largest_us_retailers_9b00dc73-a938-46cd-af17-fcb2bd67301f.csv')
df
df.mean()
I. Preguntas del negocio
df.columns
DF=df[['Company','Sales']]
filtro=DF[DF.Company != 'Walmart US']
filtro.mean()
Sc=df[['Company','Sales']]
Sc.median()
td=df[['Company','Stores']]
sns.histplot(x=td.Stores,y=td.Company,bins=15)
plt.title('COMPANY VS STORES ')
plt.show()
td.median()
td.min()
StvsSt=df[['Sales','Stores','Company']]
sns.jointplot(x=StvsSt.Stores ,y=StvsSt.Sales ,hue_order=StvsSt.Company)
plt.title('Ventas Vs Tiendas', loc='left')
plt.show()
sns.barplot(x=StvsSt.Stores ,y=StvsSt.Sales ,order=StvsSt.sort_values('Sales',ascending=False).Stores,ci=False)
plt.xticks(rotation=90)
plt.title('Sales Vs Stores')
plt.legend(bbox_to_anchor = (1 , 1 ), loc = 'upper left', borderaxespad = 2 )
plt.show()
DFR=df['Sales'].max()-df['Sales'].min()
DFR
mt=df[['Company','Sales','Stores']]
mt.sort_values('Stores',ascending=False).head(5)
mt.sort_values(['Sales','Stores'],ascending=[False,False]).head(5)
Cm=df[['Company','Sales/Avg. Store']].sort_values('Sales/Avg. Store',ascending=False)
Cm
Ratio_pad.plot(kind='bar')
plt.xlabel('Companies')
plt.ylabel('Ratio Sales/Stores')
plt.title('Ratio Sales/Stores')