You are on page 1of 2

PAULA ANDREA TAMAYO ALVAREZ

18:49
p1 = df['CausaConductorIDesc'].value_counts() print(p1[1:20]) p1[1:20].plot.barh()
PAULA ANDREA TAMAYO ALVAREZ
18:58
p2 = p1.filter(like='VELOCIDAD', axis=0) p_2 = p1.filter(like='EMBRIAGUEZ', axis=0).sum() explo =
(0.5, 0.1, 0) dfp2 = pd.DataFrame({'Total': [p2[0], p_2, (35200-p2[0]-p_2)]},
index=['ExcesoVelocidad', 'Alicoramiento', 'Otros']) print(dfp2) plt.pie(dfp2['Total'], explode=explo,
labels=dfp2.index, shadow=True, startangle=140, pctdistance=0.85, autopct='%1.1f%%')
centre_circle = plt.Circle((0,0),0.70,fc='white') fig = plt.gcf() fig.gca().add_artist(centre_circle)
plt.tight_layout() plt.show()
Juan Morales
19:00
df = pd.read_csv(r'C:\Users\dhjmo\Anaconda\archivo.csv') df
PAULA ANDREA TAMAYO ALVAREZ
19:02
p3 = df['GravedadNombre'].value_counts() print(p3) plt.pie(p3, labels=p3.index, shadow=True,
startangle=90, autopct='%1.1f%%') plt.axis('equal') plt.tight_layout() plt.show()
PAULA ANDREA TAMAYO ALVAREZ
19:12
p4 = df2['Sexo'].value_counts() p4_1 = df2_1['Sexo'].value_counts() print('AÑO 2016 \n',p4)
print('AÑO 2018 \n',p4_1) n_groups = 2 means_hombre = (p4[0], p4_1[0]) means_mujer = (p4[1],
p4_1[1]) # create plot fig, ax = plt.subplots() index = np.arange(n_groups) bar_width = 0.35 opacity
= 0.8 rects1 = plt.bar(index, means_hombre, bar_width, alpha=opacity, color='b', label='Hombres')
rects2 = plt.bar(index + bar_width, means_mujer, bar_width
PAULA ANDREA TAMAYO ALVAREZ
19:13
p4 = df2['Sexo'].value_counts() p4_1 = df2_1['Sexo'].value_counts() print('AÑO 2016 \n',p4)
print('AÑO 2018 \n',p4_1)
n_groups = 2 means_hombre = (p4[0], p4_1[0]) means_mujer = (p4[1], p4_1[1])
# create plot fig, ax = plt.subplots() index = np.arange(n_groups) bar_width = 0.35 opacity = 0.8
rects1 = plt.bar(index, means_hombre, bar_width, alpha=opacity, color='b', label='Hombres') rects2
= plt.bar(index + bar_width, means_mujer, bar_width, alpha=opacity, color='g', label='Mujeres')
plt.xlabel('Sexo') plt.ylabel('Cantidad') plt.title('Proporcion Hombres y Mujeres en Accidentes')
plt.xticks(index + bar_width, ('2016', '2017')) plt.legend() plt.tight_layout() plt.show()
PAULA ANDREA TAMAYO ALVAREZ
19:29
te invito a que te unas a https://t.me/joinchat/L7MMb8BwdTA4MmEx
PAULA ANDREA TAMAYO ALVAREZ
19:47
df_p.groupby(['Estado civil','Sexo'])['Estado civil'].size().unstack().plot(kind='bar',stacked=True)
df_p = df2.copy() def columns_to_numeric(df, column_list): df[column_list] =
df[column_list].apply(pd.to_numeric, errors='coerce') df[column_list] = df[column_list].fillna(0)
df[column_list] = df[column_list].astype(int) columns_to_numeric(df_p, 'Edad') df_p2 =
df_p.query('Edad >= 18 & Edad <= 30') df_p2.groupby(['Edad','Sexo'])
['Edad'].size().unstack().plot(kind='barh',stacked=True) plt.show()

You might also like