Informe de aportes hidrológicos para el año 2004

Este es un ejemplo de clase sobre la manipulación de archivos

  • item 1
  • item 2
  • item 3

In [59]:
import pandas as pd

In [60]:
pd.read_csv('AportesDiario_2004.csv',sep=';',decimal=',',thousands='.',skiprows=2)


Out[60]:
Fecha Region Hidrologica Nombre Rio Aportes Caudal m3/s Aportes Energia kWh Aportes %
0 1/01/2004 ANTIOQUIA A. SAN LORENZO 17.56 3910000.0 72,27%
1 1/01/2004 ANTIOQUIA CONCEPCION 6.15 1385300.0 123,69%
2 1/01/2004 ANTIOQUIA DESV. EEPPM (NEC,PAJ,DOL) 11.43 2574700.0 147,13%
3 1/01/2004 ANTIOQUIA GRANDE 18.65 4563500.0 79,23%
4 1/01/2004 ANTIOQUIA GUADALUPE 11.28 2540900.0 80,15%
5 1/01/2004 ANTIOQUIA GUATAPE 32.71 5405100.0 141,49%
6 1/01/2004 ANTIOQUIA MIEL I 50.63 2214100.0 63,99%
7 1/01/2004 ANTIOQUIA NARE 20.16 7057000.0 56,73%
8 1/01/2004 ANTIOQUIA PORCE II 64.61 3242100.0 120,97%
9 1/01/2004 ANTIOQUIA SAN CARLOS 12.80 1588700.0 70,92%
10 1/01/2004 ANTIOQUIA TENCHE 1.81 407700.0 66,84%
11 1/01/2004 CARIBE SINU URRA 152.23 1694100.0 86,88%
12 1/01/2004 CENTRO BOGOTA N.R. 9.56 4152000.0 109,55%
13 1/01/2004 CENTRO MAGDALENA BETANIA 194.95 2906000.0 68,54%
14 1/01/2004 CENTRO PRADO 3.84 42100.0 8,10%
15 1/01/2004 ORIENTE BATA 18.31 3013500.0 116,35%
16 1/01/2004 ORIENTE CHUZA 1.96 851300.0 62,14%
17 1/01/2004 ORIENTE GUAVIO 17.62 4231400.0 93,62%
18 1/01/2004 RIOS ESTIMADOS OTROS RIOS (ESTIMADOS) NaN 2755400.0 83,24%
19 1/01/2004 VALLE ALTOANCHICAYA 29.75 3164200.0 72,41%
20 1/01/2004 VALLE CALIMA 13.89 647800.0 124,58%
21 1/01/2004 VALLE CAUCA SALVAJINA 122.69 2724000.0 73,42%
22 1/01/2004 VALLE DIGUA 22.45 350800.0 85,56%
23 1/01/2004 VALLE FLORIDA II 13.51 270200.0 207,85%
24 2/01/2004 ANTIOQUIA A. SAN LORENZO 17.18 3825300.0 70,71%
25 2/01/2004 ANTIOQUIA CONCEPCION 6.13 1380800.0 123,29%
26 2/01/2004 ANTIOQUIA DESV. EEPPM (NEC,PAJ,DOL) 11.39 2565700.0 146,61%
27 2/01/2004 ANTIOQUIA GRANDE 17.73 4338400.0 75,32%
28 2/01/2004 ANTIOQUIA GUADALUPE 20.30 4572800.0 144,25%
29 2/01/2004 ANTIOQUIA GUATAPE 18.00 2974400.0 77,86%
... ... ... ... ... ... ...
8754 30/12/2004 RIOS ESTIMADOS OTROS RIOS (ESTIMADOS) NaN 2604500.0 63,52%
8755 30/12/2004 VALLE ALTOANCHICAYA 36.49 3859200.0 70,55%
8756 30/12/2004 VALLE CALIMA 10.85 505900.0 69,30%
8757 30/12/2004 VALLE CAUCA SALVAJINA 152.63 3381400.0 71,64%
8758 30/12/2004 VALLE DIGUA 26.12 406600.0 71,33%
8759 30/12/2004 VALLE FLORIDA II 8.23 164600.0 91,44%
8760 31/12/2004 ANTIOQUIA A. SAN LORENZO 18.82 4112600.0 60,13%
8761 31/12/2004 ANTIOQUIA CONCEPCION 5.16 1161900.0 77,46%
8762 31/12/2004 ANTIOQUIA DESV. EEPPM (NEC,PAJ,DOL) 9.57 2154900.0 94,10%
8763 31/12/2004 ANTIOQUIA GRANDE 23.37 5699700.0 71,25%
8764 31/12/2004 ANTIOQUIA GUADALUPE 9.92 2233700.0 52,68%
8765 31/12/2004 ANTIOQUIA GUATAPE 18.18 2939300.0 58,20%
8766 31/12/2004 ANTIOQUIA MIEL I 76.67 3356700.0 72,66%
8767 31/12/2004 ANTIOQUIA NARE 29.37 10178000.0 59,42%
8768 31/12/2004 ANTIOQUIA PORCE II 74.85 3701300.0 105,15%
8769 31/12/2004 ANTIOQUIA SAN CARLOS 14.26 1717800.0 51,28%
8770 31/12/2004 ANTIOQUIA TENCHE 2.34 526900.0 61,99%
8771 31/12/2004 CARIBE SINU URRA 163.31 1813900.0 56,68%
8772 31/12/2004 CENTRO BOGOTA N.R. 3.81 1654700.0 16,97%
8773 31/12/2004 CENTRO MAGDALENA BETANIA 253.18 3760000.0 67,75%
8774 31/12/2004 CENTRO PRADO 30.68 329100.0 45,08%
8775 31/12/2004 ORIENTE BATA 23.01 3783700.0 67,57%
8776 31/12/2004 ORIENTE CHUZA 0.00 NaN NaN
8777 31/12/2004 ORIENTE GUAVIO 16.72 4013800.0 52,61%
8778 31/12/2004 RIOS ESTIMADOS OTROS RIOS (ESTIMADOS) NaN 2358400.0 57,52%
8779 31/12/2004 VALLE ALTOANCHICAYA 23.50 2485400.0 45,44%
8780 31/12/2004 VALLE CALIMA 9.16 427100.0 58,51%
8781 31/12/2004 VALLE CAUCA SALVAJINA 151.79 3362800.0 71,25%
8782 31/12/2004 VALLE DIGUA 20.79 323600.0 56,77%
8783 31/12/2004 VALLE FLORIDA II 7.20 144000.0 80,00%

8784 rows × 6 columns


In [61]:
x=pd.read_csv('AportesDiario_2004.csv',sep=';',decimal=',',thousands='.',skiprows=2)

In [62]:
x.head()


Out[62]:
Fecha Region Hidrologica Nombre Rio Aportes Caudal m3/s Aportes Energia kWh Aportes %
0 1/01/2004 ANTIOQUIA A. SAN LORENZO 17.56 3910000.0 72,27%
1 1/01/2004 ANTIOQUIA CONCEPCION 6.15 1385300.0 123,69%
2 1/01/2004 ANTIOQUIA DESV. EEPPM (NEC,PAJ,DOL) 11.43 2574700.0 147,13%
3 1/01/2004 ANTIOQUIA GRANDE 18.65 4563500.0 79,23%
4 1/01/2004 ANTIOQUIA GUADALUPE 11.28 2540900.0 80,15%

In [63]:
x.tail()


Out[63]:
Fecha Region Hidrologica Nombre Rio Aportes Caudal m3/s Aportes Energia kWh Aportes %
8779 31/12/2004 VALLE ALTOANCHICAYA 23.50 2485400.0 45,44%
8780 31/12/2004 VALLE CALIMA 9.16 427100.0 58,51%
8781 31/12/2004 VALLE CAUCA SALVAJINA 151.79 3362800.0 71,25%
8782 31/12/2004 VALLE DIGUA 20.79 323600.0 56,77%
8783 31/12/2004 VALLE FLORIDA II 7.20 144000.0 80,00%

In [64]:
x[x['Region Hidrologica']=='ANTIOQUIA']


Out[64]:
Fecha Region Hidrologica Nombre Rio Aportes Caudal m3/s Aportes Energia kWh Aportes %
0 1/01/2004 ANTIOQUIA A. SAN LORENZO 17.56 3910000.0 72,27%
1 1/01/2004 ANTIOQUIA CONCEPCION 6.15 1385300.0 123,69%
2 1/01/2004 ANTIOQUIA DESV. EEPPM (NEC,PAJ,DOL) 11.43 2574700.0 147,13%
3 1/01/2004 ANTIOQUIA GRANDE 18.65 4563500.0 79,23%
4 1/01/2004 ANTIOQUIA GUADALUPE 11.28 2540900.0 80,15%
5 1/01/2004 ANTIOQUIA GUATAPE 32.71 5405100.0 141,49%
6 1/01/2004 ANTIOQUIA MIEL I 50.63 2214100.0 63,99%
7 1/01/2004 ANTIOQUIA NARE 20.16 7057000.0 56,73%
8 1/01/2004 ANTIOQUIA PORCE II 64.61 3242100.0 120,97%
9 1/01/2004 ANTIOQUIA SAN CARLOS 12.80 1588700.0 70,92%
10 1/01/2004 ANTIOQUIA TENCHE 1.81 407700.0 66,84%
24 2/01/2004 ANTIOQUIA A. SAN LORENZO 17.18 3825300.0 70,71%
25 2/01/2004 ANTIOQUIA CONCEPCION 6.13 1380800.0 123,29%
26 2/01/2004 ANTIOQUIA DESV. EEPPM (NEC,PAJ,DOL) 11.39 2565700.0 146,61%
27 2/01/2004 ANTIOQUIA GRANDE 17.73 4338400.0 75,32%
28 2/01/2004 ANTIOQUIA GUADALUPE 20.30 4572800.0 144,25%
29 2/01/2004 ANTIOQUIA GUATAPE 18.00 2974400.0 77,86%
30 2/01/2004 ANTIOQUIA MIEL I 70.57 3086100.0 89,19%
31 2/01/2004 ANTIOQUIA NARE 17.93 6276300.0 50,45%
32 2/01/2004 ANTIOQUIA PORCE II 64.20 3221500.0 120,21%
33 2/01/2004 ANTIOQUIA SAN CARLOS 11.84 1469500.0 65,60%
34 2/01/2004 ANTIOQUIA TENCHE 3.52 792900.0 129,98%
48 3/01/2004 ANTIOQUIA A. SAN LORENZO 17.00 3785300.0 69,97%
49 3/01/2004 ANTIOQUIA CONCEPCION 6.17 1389800.0 124,09%
50 3/01/2004 ANTIOQUIA DESV. EEPPM (NEC,PAJ,DOL) 11.46 2581500.0 147,51%
51 3/01/2004 ANTIOQUIA GRANDE 17.48 4277200.0 74,26%
52 3/01/2004 ANTIOQUIA GUADALUPE 6.10 1374100.0 43,35%
53 3/01/2004 ANTIOQUIA GUATAPE 12.87 2126700.0 55,67%
54 3/01/2004 ANTIOQUIA MIEL I 46.76 2044800.0 59,10%
55 3/01/2004 ANTIOQUIA NARE 20.89 7312500.0 58,78%
... ... ... ... ... ... ...
8715 29/12/2004 ANTIOQUIA GRANDE 26.05 6353300.0 79,42%
8716 29/12/2004 ANTIOQUIA GUADALUPE 10.66 2400400.0 56,61%
8717 29/12/2004 ANTIOQUIA GUATAPE 26.80 4332900.0 85,80%
8718 29/12/2004 ANTIOQUIA MIEL I 82.77 3623700.0 78,44%
8719 29/12/2004 ANTIOQUIA NARE 32.64 11311200.0 66,03%
8720 29/12/2004 ANTIOQUIA PORCE II 85.86 4245700.0 120,62%
8721 29/12/2004 ANTIOQUIA SAN CARLOS 14.65 1764800.0 52,68%
8722 29/12/2004 ANTIOQUIA TENCHE 0.71 159900.0 18,81%
8736 30/12/2004 ANTIOQUIA A. SAN LORENZO 19.09 4171600.0 60,99%
8737 30/12/2004 ANTIOQUIA CONCEPCION 5.22 1175400.0 78,36%
8738 30/12/2004 ANTIOQUIA DESV. EEPPM (NEC,PAJ,DOL) 9.69 2181900.0 95,28%
8739 30/12/2004 ANTIOQUIA GRANDE 22.12 5394800.0 67,44%
8740 30/12/2004 ANTIOQUIA GUADALUPE 10.72 2413900.0 56,93%
8741 30/12/2004 ANTIOQUIA GUATAPE 26.67 4311900.0 85,38%
8742 30/12/2004 ANTIOQUIA MIEL I 71.47 3129000.0 67,73%
8743 30/12/2004 ANTIOQUIA NARE 24.47 8480000.0 49,50%
8744 30/12/2004 ANTIOQUIA PORCE II 73.77 3647900.0 103,63%
8745 30/12/2004 ANTIOQUIA SAN CARLOS 14.36 1729900.0 51,64%
8746 30/12/2004 ANTIOQUIA TENCHE 0.72 162100.0 19,07%
8760 31/12/2004 ANTIOQUIA A. SAN LORENZO 18.82 4112600.0 60,13%
8761 31/12/2004 ANTIOQUIA CONCEPCION 5.16 1161900.0 77,46%
8762 31/12/2004 ANTIOQUIA DESV. EEPPM (NEC,PAJ,DOL) 9.57 2154900.0 94,10%
8763 31/12/2004 ANTIOQUIA GRANDE 23.37 5699700.0 71,25%
8764 31/12/2004 ANTIOQUIA GUADALUPE 9.92 2233700.0 52,68%
8765 31/12/2004 ANTIOQUIA GUATAPE 18.18 2939300.0 58,20%
8766 31/12/2004 ANTIOQUIA MIEL I 76.67 3356700.0 72,66%
8767 31/12/2004 ANTIOQUIA NARE 29.37 10178000.0 59,42%
8768 31/12/2004 ANTIOQUIA PORCE II 74.85 3701300.0 105,15%
8769 31/12/2004 ANTIOQUIA SAN CARLOS 14.26 1717800.0 51,28%
8770 31/12/2004 ANTIOQUIA TENCHE 2.34 526900.0 61,99%

4026 rows × 6 columns


In [66]:
len(x[x['Region Hidrologica']=='ANTIOQUIA'])


Out[66]:
4026

In [68]:
n=set(x['Nombre Rio'])
n


Out[68]:
{'A. SAN LORENZO',
 'ALTOANCHICAYA',
 'BATA',
 'BOGOTA N.R.',
 'CALIMA',
 'CAUCA SALVAJINA',
 'CHUZA',
 'CONCEPCION',
 'DESV. EEPPM (NEC,PAJ,DOL)',
 'DIGUA',
 'FLORIDA II',
 'GRANDE',
 'GUADALUPE',
 'GUATAPE',
 'GUAVIO',
 'MAGDALENA BETANIA',
 'MIEL I',
 'NARE',
 'OTROS RIOS (ESTIMADOS)',
 'PORCE II',
 'PRADO',
 'SAN CARLOS',
 'SINU URRA',
 'TENCHE'}

In [69]:
x.groupby('Nombre Rio').mean()


Out[69]:
Aportes Caudal m3/s Aportes Energia kWh
Nombre Rio
A. SAN LORENZO 36.466612 8.105400e+06
ALTOANCHICAYA 43.468716 4.620596e+06
BATA 95.478989 1.571243e+07
BOGOTA N.R. 28.051803 1.277674e+07
CALIMA 11.922077 5.560117e+05
CAUCA SALVAJINA 113.523306 2.519614e+06
CHUZA 9.742486 4.337967e+06
CONCEPCION 6.606667 1.488170e+06
DESV. EEPPM (NEC,PAJ,DOL) 8.312240 2.291866e+06
DIGUA 27.529536 4.299954e+05
FLORIDA II 10.712486 2.148367e+05
GRANDE 27.511967 6.729973e+06
GUADALUPE 20.167978 4.542911e+06
GUATAPE 34.103033 5.624479e+06
GUAVIO 85.884563 2.062469e+07
MAGDALENA BETANIA 374.490765 5.580630e+06
MIEL I 78.433251 3.430428e+06
NARE 49.711612 1.738808e+07
OTROS RIOS (ESTIMADOS) NaN 3.700457e+06
PORCE II 99.292650 4.976887e+06
PRADO 45.597268 4.984191e+05
SAN CARLOS 24.910492 3.084509e+06
SINU URRA 284.444208 3.165074e+06
TENCHE 3.900874 8.786683e+05

In [70]:
import statistics

In [71]:
for y in n:
    z=x[x['Nombre Rio']==y]['Aportes Energia kWh']
    if len(z)>0:
        print(y,statistics.mean(z.values[:]))


GUAVIO 20624689.3443
BATA 15712428.4153
OTROS RIOS (ESTIMADOS) 3700456.8306
GRANDE 6729973.22404
MIEL I 3430428.4153
SAN CARLOS 3084508.74317
DIGUA 429995.355191
ALTOANCHICAYA 4620595.90164
GUADALUPE 4542910.92896
NARE 17388083.6066
CHUZA nan
FLORIDA II nan
MAGDALENA BETANIA 5580630.32787
CAUCA SALVAJINA 2519614.48087
A. SAN LORENZO 8105399.72678
CALIMA 556011.748634
TENCHE 878668.306011
GUATAPE 5624479.23497
CONCEPCION 1488170.4918
SINU URRA 3165074.04372
PORCE II 4976887.15847
DESV. EEPPM (NEC,PAJ,DOL) nan
BOGOTA N.R. nan
PRADO 498419.125683