import pandas as pd
# URL del archivo de Google Sheets en formato CSV
sheet_url = "https://docs.google.com/spreadsheets/d/1U3JiVuxjDcvaIoLw9XkW3JKfuh-8_3Pc/export?format=csv"
sheet_url_2019 = "https://docs.google.com/spreadsheets/d/1lr5C-auB3WUs9xYgTyY4whBa8k4L9wesQbJT3TYCIR8/export?format=csv"
# Leer los datos
df = pd.read_csv(sheet_url)
df_2019 = pd.read_csv(sheet_url_2019)
# Convertir las columnas necesarias a números y reemplazar comas por puntos
df['CARGA (Ton)'] = df['CARGA (Ton)'].str.replace(',', '.').astype(float)
df_2019['CARGA (Ton)'] = df_2019['CARGA (Ton)'].str.replace(',', '.').astype(float)
# Mostrar las primeras filas del DataFrame
# print(df.head())
# Obtener información general del DataFrame
# print(df.info())
# Obtener estadísticas descriptivas del DataFrame
# print(df.describe())
# Mostrar las ultimas filas del DataFrame
print(df.tail())
df['PASAJEROS'] = pd.to_numeric(df['PASAJEROS'], errors='coerce')
df['CARGA (Ton)'] = pd.to_numeric(df['CARGA (Ton)'], errors='coerce')
df['CORREO'] = pd.to_numeric(df['CORREO'], errors='coerce')
<ipython-input-1-67a7f29e726d>:8: DtypeWarning: Columns (22,23) have mixed types. Specify dtype option on import or set low_memory=False. df = pd.read_csv(sheet_url)
Año Mes Cod_Operador Operador Grupo ORIG_1 DEST_1 \ 243222 2024 6 JA JETSMART JETSMART GIG SCL 243223 2024 6 JA JETSMART JETSMART GRU SCL 243224 2024 6 JA JETSMART JETSMART MDE SCL 243225 2024 6 JZ JETSMART PERÚ JETSMART SCL LIM 243226 2024 6 JZ JETSMART PERÚ JETSMART LIM SCL ORIG_1_N DEST_1_N ORIG_1_PAIS ... ORIG_2_PAIS DEST_2_PAIS \ 243222 RIO DE JANEIRO SANTIAGO BRASIL ... CHILE BRASIL 243223 SAO PAULO SANTIAGO BRASIL ... CHILE BRASIL 243224 MEDELLIN SANTIAGO COLOMBIA ... CHILE COLOMBIA 243225 SANTIAGO LIMA CHILE ... CHILE PERU 243226 LIMA SANTIAGO PERU ... CHILE PERU OPER_2 NAC PAX_LIB PASAJEROS CAR_LIB CARGA (Ton) CORREO \ 243222 LLEGAN INTERNACIONAL 0.0 0.0 0 0.3152 0.0 243223 LLEGAN INTERNACIONAL 0.0 0.0 0 3.2780 0.0 243224 LLEGAN INTERNACIONAL 0.0 0.0 0 0.2680 0.0 243225 SALEN INTERNACIONAL 0.0 0.0 0 14.1150 0.0 243226 LLEGAN INTERNACIONAL 0.0 0.0 0 19.5189 0.0 Distancia 243222 2931.0 243223 2585.0 243224 4480.0 243225 2459.0 243226 2459.0 [5 rows x 25 columns]
# Filtrar los datos para el año 2024
df_2024 = df[df['Año'] == 2024]
# Agrupar por mes y tipo de tráfico
pasajeros_2024 = df_2024.groupby(['Mes', 'NAC'])['PASAJEROS'].sum().unstack().fillna(0)
carga_2024 = df_2024.groupby(['Mes', 'NAC'])['CARGA (Ton)'].sum().unstack().fillna(0)
correo_2024 = df_2024.groupby(['Mes', 'NAC'])['CORREO'].sum().unstack().fillna(0)
# Calcular los totales
pasajeros_2024['Total'] = pasajeros_2024.sum(axis=1)
carga_2024['Total'] = carga_2024.sum(axis=1)
correo_2024['Total'] = correo_2024.sum(axis=1)
# Calcular los totales generales
total_pasajeros_2024 = pasajeros_2024.sum()
total_carga_2024 = carga_2024.sum()
total_correo_2024 = correo_2024.sum()
# Filtrar los datos para los años de referencia
df_2023 = df[df['Año'] == 2023]
# df_2019 = df[df['Año'] == 2019]
# Agrupar por mes y tipo de tráfico para 2023 y 2019
pasajeros_2023 = df_2023.groupby(['Mes', 'NAC'])['PASAJEROS'].sum().unstack().fillna(0)
carga_2023 = df_2023.groupby(['Mes', 'NAC'])['CARGA (Ton)'].sum().unstack().fillna(0)
correo_2023 = df_2023.groupby(['Mes', 'NAC'])['CORREO'].sum().unstack().fillna(0)
pasajeros_2019 = df_2019.groupby(['Mes', 'NAC'])['PASAJEROS'].sum().unstack().fillna(0)
carga_2019 = df_2019.groupby(['Mes', 'NAC'])['CARGA (Ton)'].sum().unstack().fillna(0)
correo_2019 = df_2019.groupby(['Mes', 'NAC'])['CORREO'].sum().unstack().fillna(0)
# Calcular los totales
pasajeros_2023['Total'] = pasajeros_2023.sum(axis=1)
carga_2023['Total'] = carga_2023.sum(axis=1)
correo_2023['Total'] = correo_2023.sum(axis=1)
pasajeros_2019['Total'] = pasajeros_2019.sum(axis=1)
carga_2019['Total'] = carga_2019.sum(axis=1)
correo_2019['Total'] = correo_2019.sum(axis=1)
# Calcular las variaciones porcentuales
variacion_24_23_pasajeros = ((pasajeros_2024 - pasajeros_2023) / pasajeros_2023) * 100
variacion_24_23_pasajeros_nacionales = ((pasajeros_2024['NACIONAL'] - pasajeros_2023['NACIONAL']) / pasajeros_2023['NACIONAL']) * 100
variacion_24_23_pasajeros_internacionales = ((pasajeros_2024['INTERNACIONAL'] - pasajeros_2023['INTERNACIONAL']) / pasajeros_2023['INTERNACIONAL']) * 100
variacion_24_19_pasajeros = ((pasajeros_2024 - pasajeros_2019) / pasajeros_2019) * 100
variacion_24_19_pasajeros_nacionales = ((pasajeros_2024['NACIONAL'] - pasajeros_2019['NACIONAL']) / pasajeros_2019['NACIONAL']) * 100
variacion_24_19_pasajeros_internacionales = ((pasajeros_2024['INTERNACIONAL'] - pasajeros_2019['INTERNACIONAL']) / pasajeros_2019['INTERNACIONAL']) * 100
variacion_24_23_carga = ((carga_2024 - carga_2023) / carga_2023) * 100
variacion_24_23_carga_nacionales = ((carga_2024['NACIONAL'] - carga_2023['NACIONAL']) / carga_2023['NACIONAL']) * 100
variacion_24_23_carga_internacionales = ((carga_2024['INTERNACIONAL'] - carga_2023['INTERNACIONAL']) / carga_2023['INTERNACIONAL']) * 100
variacion_24_19_carga = ((carga_2024 - carga_2019) / carga_2019) * 100
variacion_24_19_carga_nacionales = ((carga_2024['NACIONAL'] - carga_2019['NACIONAL']) / carga_2019['NACIONAL']) * 100
variacion_24_19_carga_internacionales = ((carga_2024['INTERNACIONAL'] - carga_2019['INTERNACIONAL']) / carga_2019['INTERNACIONAL']) * 100
variacion_24_23_correo = ((correo_2024 - correo_2023) / correo_2023) * 100
variacion_24_23_correo_nacionales = ((correo_2024['NACIONAL'] - correo_2023['NACIONAL']) / correo_2023['NACIONAL']) * 100
variacion_24_23_correo_internacionales = ((correo_2024['INTERNACIONAL'] - correo_2023['INTERNACIONAL']) / correo_2023['INTERNACIONAL']) * 100
variacion_24_19_correo = ((correo_2024 - correo_2019) / correo_2019) * 100
variacion_24_19_correo_nacionales = ((correo_2024['NACIONAL'] - correo_2019['NACIONAL']) / correo_2019['NACIONAL']) * 100
variacion_24_19_correo_internacionales = ((correo_2024['INTERNACIONAL'] - correo_2019['INTERNACIONAL']) / correo_2019['INTERNACIONAL']) * 100
# Crear DataFrame de resumen para pasajeros
resumen_pasajeros = pasajeros_2024.copy()
# Cambiar múltiples nombres de columnas
resumen_pasajeros = resumen_pasajeros.rename(columns={
'NACIONAL': 'NACIONAL 2024',
'INTERNACIONAL': 'INTERNACIONAL 2024',
'Total': 'Total 2024',
})
# Especifica el nuevo orden de las columnas
nuevo_orden = ['NACIONAL 2024', 'INTERNACIONAL 2024', 'Total 2024']
# Reordenar el DataFrame
resumen_pasajeros = resumen_pasajeros[nuevo_orden]
resumen_pasajeros['NACIONAL 2024'] = pasajeros_2024['NACIONAL'].apply(lambda x: '{:,.0f}'.format(x))
resumen_pasajeros['INTERNACIONAL 2024'] = pasajeros_2024['INTERNACIONAL'].apply(lambda x: '{:,.0f}'.format(x))
resumen_pasajeros['Total 2024'] = pasajeros_2024['Total'].apply(lambda x: '{:,.0f}'.format(x))
# resumen_pasajeros['NACIONAL 2023'] = pasajeros_2023['NACIONAL'].apply(lambda x: '{:,.0f}'.format(x))
# resumen_pasajeros['INTERNACIONAL 2023'] = pasajeros_2023['INTERNACIONAL'].apply(lambda x: '{:,.0f}'.format(x))
# resumen_pasajeros['Total 2023'] = pasajeros_2023['Total'].apply(lambda x: '{:,.0f}'.format(x))
# resumen_pasajeros['NACIONAL 2019'] = pasajeros_2019['NACIONAL'].apply(lambda x: '{:,.0f}'.format(x))
# resumen_pasajeros['INTERNACIONAL 2019'] = pasajeros_2019['INTERNACIONAL'].apply(lambda x: '{:,.0f}'.format(x))
# resumen_pasajeros['Total 2019'] = pasajeros_2019['Total'].apply(lambda x: '{:,.0f}'.format(x))
resumen_pasajeros['Var 24/23 (%) NAC'] = variacion_24_23_pasajeros_nacionales.apply(lambda x: '{:.2f}'.format(x))
resumen_pasajeros['Var 24/23 (%) INT'] = variacion_24_23_pasajeros_internacionales.apply(lambda x: '{:.2f}'.format(x))
resumen_pasajeros['Var 24/23 (%) TOT'] = variacion_24_23_pasajeros['Total'].apply(lambda x: '{:.2f}'.format(x))
resumen_pasajeros['Var 24/19 (%) NAC'] = variacion_24_19_pasajeros_nacionales.apply(lambda x: '{:.2f}'.format(x))
resumen_pasajeros['Var 24/19 (%) INT'] = variacion_24_19_pasajeros_internacionales.apply(lambda x: '{:.2f}'.format(x))
resumen_pasajeros['Var 24/19 (%) TOT'] = variacion_24_19_pasajeros['Total'].apply(lambda x: '{:.2f}'.format(x))
print("Resumen Mensual - Tráfico Aéreo de Pasajeros")
resumen_pasajeros
Resumen Mensual - Tráfico Aéreo de Pasajeros
NAC | NACIONAL 2024 | INTERNACIONAL 2024 | Total 2024 | Var 24/23 (%) NAC | Var 24/23 (%) INT | Var 24/23 (%) TOT | Var 24/19 (%) NAC | Var 24/19 (%) INT | Var 24/19 (%) TOT |
---|---|---|---|---|---|---|---|---|---|
Mes | |||||||||
1 | 1,654,556 | 1,061,493 | 2,716,049 | 21.24 | 22.23 | 21.63 | 6.10 | -3.24 | 2.24 |
2 | 1,538,078 | 1,017,063 | 2,555,141 | 20.38 | 23.99 | 21.80 | 6.03 | 0.44 | 3.73 |
3 | 1,351,012 | 978,489 | 2,329,501 | 6.34 | 24.09 | 13.14 | 5.91 | -3.48 | 1.75 |
4 | 1,255,579 | 813,295 | 2,068,874 | 10.30 | 17.46 | 13.01 | 10.51 | -7.41 | 2.70 |
5 | 1,224,246 | 838,044 | 2,062,290 | 5.79 | 21.82 | 11.76 | 10.16 | -5.62 | 3.15 |
6 | 1,148,996 | 893,862 | 2,042,858 | 2.70 | 23.74 | 10.96 | 11.34 | 3.95 | 7.98 |
# Crear DataFrame de resumen para carga
resumen_carga = carga_2024.copy()
# Cambiar múltiples nombres de columnas
resumen_carga = resumen_carga.rename(columns={
'NACIONAL': 'NACIONAL 2024',
'INTERNACIONAL': 'INTERNACIONAL 2024',
'Total': 'Total 2024',
})
# Especifica el nuevo orden de las columnas
nuevo_orden = ['NACIONAL 2024', 'INTERNACIONAL 2024', 'Total 2024']
# Reordenar el DataFrame
resumen_carga = resumen_carga[nuevo_orden]
resumen_carga['NACIONAL 2024'] = carga_2024['NACIONAL'].apply(lambda x: '{:,.0f}'.format(x))
resumen_carga['INTERNACIONAL 2024'] = carga_2024['INTERNACIONAL'].apply(lambda x: '{:,.0f}'.format(x))
resumen_carga['Total 2024'] = carga_2024['Total'].apply(lambda x: '{:,.0f}'.format(x))
resumen_carga['Var 24/23 (%) NAC'] = variacion_24_23_carga_nacionales.apply(lambda x: '{:.2f}'.format(x))
resumen_carga['Var 24/23 (%) INT'] = variacion_24_23_carga_internacionales.apply(lambda x: '{:.2f}'.format(x))
resumen_carga['Var 24/23 (%) TOT'] = variacion_24_23_carga['Total'].apply(lambda x: '{:.2f}'.format(x))
resumen_carga['Var 24/19 (%) NAC'] = variacion_24_19_carga_nacionales.apply(lambda x: '{:.2f}'.format(x))
resumen_carga['Var 24/19 (%) INT'] = variacion_24_19_carga_internacionales.apply(lambda x: '{:.2f}'.format(x))
resumen_carga['Var 24/19 (%) TOT'] = variacion_24_19_carga['Total'].apply(lambda x: '{:.2f}'.format(x))
print("\nResumen Mensual - Tráfico Aéreo de Carga")
resumen_carga
Resumen Mensual - Tráfico Aéreo de Carga
NAC | NACIONAL 2024 | INTERNACIONAL 2024 | Total 2024 | Var 24/23 (%) NAC | Var 24/23 (%) INT | Var 24/23 (%) TOT | Var 24/19 (%) NAC | Var 24/19 (%) INT | Var 24/19 (%) TOT |
---|---|---|---|---|---|---|---|---|---|
Mes | |||||||||
1 | 2,451 | 36,412 | 38,863 | -14.66 | 13.06 | 10.79 | -3.43 | 22.89 | 20.81 |
2 | 2,507 | 33,416 | 35,922 | -6.66 | 4.11 | 3.28 | 5.02 | 19.79 | 18.63 |
3 | 2,693 | 33,602 | 36,296 | 4.43 | -12.05 | -11.00 | -6.87 | -8.17 | -8.07 |
4 | 2,604 | 31,258 | 33,862 | 21.99 | -7.17 | -5.43 | -2.30 | 1.18 | 0.90 |
5 | 2,639 | 34,597 | 37,237 | 2.79 | 7.62 | 7.26 | -8.34 | 12.33 | 10.56 |
6 | 2,025 | 31,798 | 33,822 | -9.53 | -0.01 | -0.63 | -32.57 | 8.76 | 4.91 |
# Crear DataFrame de resumen para correo
resumen_correo = correo_2024.copy()
# Cambiar múltiples nombres de columnas
resumen_correo = resumen_correo.rename(columns={
'NACIONAL': 'NACIONAL 2024',
'INTERNACIONAL': 'INTERNACIONAL 2024',
'Total': 'Total 2024',
})
# Especifica el nuevo orden de las columnas
nuevo_orden = ['NACIONAL 2024', 'INTERNACIONAL 2024', 'Total 2024']
# Reordenar el DataFrame
resumen_correo = resumen_correo[nuevo_orden]
resumen_correo['NACIONAL 2024'] = correo_2024['NACIONAL'].apply(lambda x: '{:,.0f}'.format(x))
resumen_correo['INTERNACIONAL 2024'] = correo_2024['INTERNACIONAL'].apply(lambda x: '{:,.0f}'.format(x))
resumen_correo['Total 2024'] = correo_2024['Total'].apply(lambda x: '{:,.0f}'.format(x))
resumen_correo['Var 24/23 (%) NAC'] = variacion_24_23_correo_nacionales.apply(lambda x: '{:.2f}'.format(x))
resumen_correo['Var 24/23 (%) INT'] = variacion_24_23_correo_internacionales.apply(lambda x: '{:.2f}'.format(x))
resumen_correo['Var 24/23 (%) TOT'] = variacion_24_23_correo['Total'].apply(lambda x: '{:.2f}'.format(x))
resumen_correo['Var 24/19 (%) NAC'] = variacion_24_19_correo_nacionales.apply(lambda x: '{:.2f}'.format(x))
resumen_correo['Var 24/19 (%) INT'] = variacion_24_19_correo_internacionales.apply(lambda x: '{:.2f}'.format(x))
resumen_correo['Var 24/19 (%) TOT'] = variacion_24_19_correo['Total'].apply(lambda x: '{:.2f}'.format(x))
print("\nResumen Mensual - Tráfico Aéreo de Correo")
resumen_correo
Resumen Mensual - Tráfico Aéreo de Correo
NAC | NACIONAL 2024 | INTERNACIONAL 2024 | Total 2024 | Var 24/23 (%) NAC | Var 24/23 (%) INT | Var 24/23 (%) TOT | Var 24/19 (%) NAC | Var 24/19 (%) INT | Var 24/19 (%) TOT |
---|---|---|---|---|---|---|---|---|---|
Mes | |||||||||
1 | 123,949 | 830,394 | 954,343 | 28.27 | 9.07 | 11.23 | 107.33 | -5.97 | 1.21 |
2 | 123,661 | 757,229 | 880,890 | 53.47 | 20.29 | 24.05 | 122.30 | -3.88 | 4.44 |
3 | 144,077 | 884,515 | 1,028,592 | 13.62 | 3.18 | 4.52 | 79.55 | -7.44 | -0.70 |
4 | 151,829 | 1,037,658 | 1,189,487 | 10.81 | 33.63 | 30.20 | 162.13 | -5.19 | 3.22 |
5 | 129,990 | 1,055,025 | 1,185,015 | -15.92 | 44.92 | 34.26 | 54.82 | -2.39 | 1.73 |
6 | 111,456 | 1,063,319 | 1,174,775 | -17.33 | 24.69 | 18.96 | 73.04 | 17.57 | 21.26 |
# Filtrar los datos para el año 2024
df_23_24 = df[df['Año'] >= 2023]
df_23_24
Año | Mes | Cod_Operador | Operador | Grupo | ORIG_1 | DEST_1 | ORIG_1_N | DEST_1_N | ORIG_1_PAIS | ... | ORIG_2_PAIS | DEST_2_PAIS | OPER_2 | NAC | PAX_LIB | PASAJEROS | CAR_LIB | CARGA (Ton) | CORREO | Distancia | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
230061 | 2023 | 1 | AC | AIR CANADA | AIR CANADA | YYZ | SCL | TORONTO | SANTIAGO | CANADA | ... | CHILE | CANADA | LLEGAN | INTERNACIONAL | 0.0 | 4646.0 | 0 | 175.5550 | 1261.0 | 8674.0 |
230062 | 2023 | 2 | AC | AIR CANADA | AIR CANADA | YYZ | SCL | TORONTO | SANTIAGO | CANADA | ... | CHILE | CANADA | LLEGAN | INTERNACIONAL | 0.0 | 4505.0 | 0 | 183.6700 | 1514.0 | 8674.0 |
230063 | 2023 | 3 | AC | AIR CANADA | AIR CANADA | YYZ | SCL | TORONTO | SANTIAGO | CANADA | ... | CHILE | CANADA | LLEGAN | INTERNACIONAL | 0.0 | 3800.0 | 0 | 159.2480 | 5057.0 | 8674.0 |
230064 | 2023 | 4 | AC | AIR CANADA | AIR CANADA | YYZ | SCL | TORONTO | SANTIAGO | CANADA | ... | CHILE | CANADA | LLEGAN | INTERNACIONAL | 0.0 | 2195.0 | 0 | 166.5220 | 3997.0 | 8674.0 |
230065 | 2023 | 5 | AC | AIR CANADA | AIR CANADA | YYZ | SCL | TORONTO | SANTIAGO | CANADA | ... | CHILE | CANADA | LLEGAN | INTERNACIONAL | 0.0 | 1911.0 | 0 | 117.2330 | 991.0 | 8674.0 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
243222 | 2024 | 6 | JA | JETSMART | JETSMART | GIG | SCL | RIO DE JANEIRO | SANTIAGO | BRASIL | ... | CHILE | BRASIL | LLEGAN | INTERNACIONAL | 0.0 | 0.0 | 0 | 0.3152 | 0.0 | 2931.0 |
243223 | 2024 | 6 | JA | JETSMART | JETSMART | GRU | SCL | SAO PAULO | SANTIAGO | BRASIL | ... | CHILE | BRASIL | LLEGAN | INTERNACIONAL | 0.0 | 0.0 | 0 | 3.2780 | 0.0 | 2585.0 |
243224 | 2024 | 6 | JA | JETSMART | JETSMART | MDE | SCL | MEDELLIN | SANTIAGO | COLOMBIA | ... | CHILE | COLOMBIA | LLEGAN | INTERNACIONAL | 0.0 | 0.0 | 0 | 0.2680 | 0.0 | 4480.0 |
243225 | 2024 | 6 | JZ | JETSMART PERÚ | JETSMART | SCL | LIM | SANTIAGO | LIMA | CHILE | ... | CHILE | PERU | SALEN | INTERNACIONAL | 0.0 | 0.0 | 0 | 14.1150 | 0.0 | 2459.0 |
243226 | 2024 | 6 | JZ | JETSMART PERÚ | JETSMART | LIM | SCL | LIMA | SANTIAGO | PERU | ... | CHILE | PERU | LLEGAN | INTERNACIONAL | 0.0 | 0.0 | 0 | 19.5189 | 0.0 | 2459.0 |
8052 rows × 25 columns
# Agrupar por mes y tipo de tráfico
pasajeros_23_24 = df_23_24.groupby(['Mes','NAC', 'ORIG_2_N','DEST_2_N', 'OPER_2', 'Año'])['PASAJEROS'].sum().unstack().fillna(0)
pasajeros_23_24
Año | 2023 | 2024 | ||||
---|---|---|---|---|---|---|
Mes | NAC | ORIG_2_N | DEST_2_N | OPER_2 | ||
1 | INTERNACIONAL | ANTOFAGASTA | CALI | LLEGAN | 2806.0 | 3912.0 |
SALEN | 2841.0 | 4182.0 | ||||
LIMA | LLEGAN | 1204.0 | 1627.0 | |||
SALEN | 1187.0 | 1622.0 | ||||
LOS ANGELES | LLEGAN | 0.0 | 0.0 | |||
... | ... | ... | ... | ... | ... | ... |
12 | NACIONAL | SANTIAGO | TEMUCO | SALEN | 49299.0 | 0.0 |
VALDIVIA | LLEGAN | 16542.0 | 0.0 | |||
SALEN | 17433.0 | 0.0 | ||||
TEMUCO | BALMACEDA | LLEGAN | 1722.0 | 0.0 | ||
SALEN | 1966.0 | 0.0 |
2456 rows × 2 columns
# Agrupar por mes y tipo de tráfico
carga_23_24 = df_23_24.groupby(['Mes','NAC', 'ORIG_2_N','DEST_2_N', 'OPER_2', 'Año'])['CARGA (Ton)'].sum().unstack().fillna(0)
carga_23_24
Año | 2023 | 2024 | ||||
---|---|---|---|---|---|---|
Mes | NAC | ORIG_2_N | DEST_2_N | OPER_2 | ||
1 | INTERNACIONAL | ANTOFAGASTA | CALI | LLEGAN | 0.000 | 0.000 |
SALEN | 0.000 | 0.000 | ||||
LIMA | LLEGAN | 0.000 | 6.313 | |||
SALEN | 0.000 | 0.000 | ||||
LOS ANGELES | LLEGAN | 0.000 | 0.066 | |||
... | ... | ... | ... | ... | ... | ... |
12 | NACIONAL | SANTIAGO | TEMUCO | SALEN | 2.538 | 0.000 |
VALDIVIA | LLEGAN | 0.000 | 0.000 | |||
SALEN | 0.550 | 0.000 | ||||
TEMUCO | BALMACEDA | LLEGAN | 0.000 | 0.000 | ||
SALEN | 0.000 | 0.000 |
2456 rows × 2 columns
correo_23_24 = df_23_24.groupby(['Mes','NAC', 'ORIG_2_N','DEST_2_N', 'OPER_2', 'Año'])['CORREO'].sum().unstack().fillna(0)
correo_23_24
Año | 2023 | 2024 | ||||
---|---|---|---|---|---|---|
Mes | NAC | ORIG_2_N | DEST_2_N | OPER_2 | ||
1 | INTERNACIONAL | ANTOFAGASTA | CALI | LLEGAN | 0.0 | 0.0 |
SALEN | 0.0 | 0.0 | ||||
LIMA | LLEGAN | 0.0 | 0.0 | |||
SALEN | 0.0 | 0.0 | ||||
LOS ANGELES | LLEGAN | 0.0 | 250.0 | |||
... | ... | ... | ... | ... | ... | ... |
12 | NACIONAL | SANTIAGO | TEMUCO | SALEN | 0.0 | 0.0 |
VALDIVIA | LLEGAN | 0.0 | 0.0 | |||
SALEN | 0.0 | 0.0 | ||||
TEMUCO | BALMACEDA | LLEGAN | 0.0 | 0.0 | ||
SALEN | 0.0 | 0.0 |
2456 rows × 2 columns
# filtrar Mes = mesanterior
from datetime import datetime
# Obtén la fecha y hora actual
now = datetime.now()
# Obtén el número del mes
month_number = now.month - 1
print(f"El número del mes anterior es: {month_number}")
mesant = month_number
pasajeros_23_24_6 = pasajeros_23_24.loc[mesant]
pasajeros_23_24_6
El número del mes anterior es: 6
Año | 2023 | 2024 | |||
---|---|---|---|---|---|
NAC | ORIG_2_N | DEST_2_N | OPER_2 | ||
INTERNACIONAL | ANTOFAGASTA | CALI | LLEGAN | 2383.0 | 1904.0 |
SALEN | 2190.0 | 1968.0 | |||
LIMA | LLEGAN | 1090.0 | 982.0 | ||
SALEN | 1083.0 | 1755.0 | |||
MIAMI | LLEGAN | 0.0 | 0.0 | ||
... | ... | ... | ... | ... | ... |
NACIONAL | SANTIAGO | TEMUCO | SALEN | 37298.0 | 37311.0 |
VALDIVIA | LLEGAN | 12968.0 | 14599.0 | ||
SALEN | 13285.0 | 14401.0 | |||
TEMUCO | BALMACEDA | LLEGAN | 1345.0 | 1351.0 | |
SALEN | 1177.0 | 1383.0 |
210 rows × 2 columns
carga_23_24_6 = carga_23_24.loc[mesant]
carga_23_24_6
Año | 2023 | 2024 | |||
---|---|---|---|---|---|
NAC | ORIG_2_N | DEST_2_N | OPER_2 | ||
INTERNACIONAL | ANTOFAGASTA | CALI | LLEGAN | 0.000 | 0.000 |
SALEN | 0.000 | 0.000 | |||
LIMA | LLEGAN | 0.000 | 0.000 | ||
SALEN | 0.000 | 0.000 | |||
MIAMI | LLEGAN | 241.371 | 164.063 | ||
... | ... | ... | ... | ... | ... |
NACIONAL | SANTIAGO | TEMUCO | SALEN | 2.926 | 3.489 |
VALDIVIA | LLEGAN | 0.000 | 0.000 | ||
SALEN | 0.502 | 0.577 | |||
TEMUCO | BALMACEDA | LLEGAN | 0.000 | 0.000 | |
SALEN | 0.000 | 0.000 |
210 rows × 2 columns
correo_23_24_6 = correo_23_24.loc[mesant]
correo_23_24_6
Año | 2023 | 2024 | |||
---|---|---|---|---|---|
NAC | ORIG_2_N | DEST_2_N | OPER_2 | ||
INTERNACIONAL | ANTOFAGASTA | CALI | LLEGAN | 0.0 | 0.0 |
SALEN | 0.0 | 0.0 | |||
LIMA | LLEGAN | 0.0 | 0.0 | ||
SALEN | 0.0 | 0.0 | |||
MIAMI | LLEGAN | 0.0 | 0.0 | ||
... | ... | ... | ... | ... | ... |
NACIONAL | SANTIAGO | TEMUCO | SALEN | 561.0 | 0.0 |
VALDIVIA | LLEGAN | 0.0 | 0.0 | ||
SALEN | 0.0 | 0.0 | |||
TEMUCO | BALMACEDA | LLEGAN | 0.0 | 0.0 | |
SALEN | 0.0 | 0.0 |
210 rows × 2 columns
df_23_24_int = df[(df['Año'] >= 2023) & (df['NAC'] == 'INTERNACIONAL')]
paises_23_24 = df_23_24_int.groupby(['Mes','NAC', 'DEST_2_PAIS', 'OPER_2', 'Año'])['PASAJEROS'].sum().unstack().fillna(0)
paises_23_24
Año | 2023 | 2024 | |||
---|---|---|---|---|---|
Mes | NAC | DEST_2_PAIS | OPER_2 | ||
1 | INTERNACIONAL | ALEMANIA | LLEGAN | 0.0 | 0.0 |
ARGENTINA | LLEGAN | 76695.0 | 91732.0 | ||
SALEN | 71507.0 | 89552.0 | |||
AUSTRALIA | LLEGAN | 6313.0 | 9457.0 | ||
SALEN | 7052.0 | 12034.0 | |||
... | ... | ... | ... | ... | ... |
12 | INTERNACIONAL | REP. COREA DEL SUR | SALEN | 0.0 | 0.0 |
REP. DOMINICANA | LLEGAN | 2028.0 | 0.0 | ||
SALEN | 2714.0 | 0.0 | |||
URUGUAY | LLEGAN | 8028.0 | 0.0 | ||
SALEN | 8684.0 | 0.0 |
556 rows × 2 columns
paises_23_24.loc[mesant]
Año | 2023 | 2024 | ||
---|---|---|---|---|
NAC | DEST_2_PAIS | OPER_2 | ||
INTERNACIONAL | ALEMANIA | LLEGAN | 0.0 | 0.0 |
ARGENTINA | LLEGAN | 70450.0 | 73932.0 | |
SALEN | 75766.0 | 79534.0 | ||
AUSTRALIA | LLEGAN | 4829.0 | 8283.0 | |
SALEN | 7478.0 | 8511.0 | ||
BELGICA | LLEGAN | 0.0 | 0.0 | |
BOLIVIA | LLEGAN | 2058.0 | 1548.0 | |
SALEN | 2335.0 | 1922.0 | ||
BRASIL | LLEGAN | 67940.0 | 115776.0 | |
SALEN | 67539.0 | 121238.0 | ||
CANADA | LLEGAN | 1881.0 | 0.0 | |
SALEN | 2884.0 | 0.0 | ||
COLOMBIA | LLEGAN | 31005.0 | 33794.0 | |
SALEN | 33087.0 | 38942.0 | ||
ECUADOR | LLEGAN | 2677.0 | 2689.0 | |
SALEN | 2897.0 | 3227.0 | ||
ESPAÑA | LLEGAN | 21618.0 | 30407.0 | |
SALEN | 23729.0 | 33596.0 | ||
ESTADOS UNIDOS | LLEGAN | 40206.0 | 41085.0 | |
SALEN | 43866.0 | 44524.0 | ||
FRANCIA | LLEGAN | 8818.0 | 9014.0 | |
SALEN | 9501.0 | 9017.0 | ||
GUATEMALA | SALEN | 0.0 | 0.0 | |
HOLANDA | LLEGAN | 1781.0 | 2085.0 | |
SALEN | 2411.0 | 2325.0 | ||
LUXEMBURGO | LLEGAN | 0.0 | 0.0 | |
MEXICO | LLEGAN | 5684.0 | 5660.0 | |
SALEN | 5869.0 | 7601.0 | ||
NIGERIA | SALEN | 0.0 | 0.0 | |
NUEVA ZELANDIA | LLEGAN | 2979.0 | 3709.0 | |
SALEN | 3513.0 | 2841.0 | ||
PANAMA | LLEGAN | 20921.0 | 20711.0 | |
SALEN | 22996.0 | 24127.0 | ||
PARAGUAY | LLEGAN | 2442.0 | 2566.0 | |
SALEN | 2346.0 | 2784.0 | ||
PERU | LLEGAN | 51804.0 | 60096.0 | |
SALEN | 58257.0 | 73130.0 | ||
QATAR | LLEGAN | 0.0 | 0.0 | |
SALEN | 0.0 | 0.0 | ||
REINO UNIDO | LLEGAN | 3227.0 | 3267.0 | |
SALEN | 3478.0 | 3559.0 | ||
REP. COREA DEL SUR | LLEGAN | 0.0 | 0.0 | |
SALEN | 0.0 | 0.0 | ||
REP. DOMINICANA | LLEGAN | 1024.0 | 2867.0 | |
SALEN | 1059.0 | 2743.0 | ||
TRINIDAD Y TOBAGO | SALEN | 0.0 | 0.0 | |
URUGUAY | LLEGAN | 6040.0 | 8728.0 | |
SALEN | 5970.0 | 8024.0 |