fiscalpy 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fiscalpy-0.0.1/LICENSE +9 -0
- fiscalpy-0.0.1/PKG-INFO +22 -0
- fiscalpy-0.0.1/README.md +9 -0
- fiscalpy-0.0.1/pyproject.toml +22 -0
- fiscalpy-0.0.1/setup.cfg +4 -0
- fiscalpy-0.0.1/src/fiscalpy/__init__.py +4 -0
- fiscalpy-0.0.1/src/fiscalpy/limpieza.py +312 -0
- fiscalpy-0.0.1/src/fiscalpy.egg-info/PKG-INFO +22 -0
- fiscalpy-0.0.1/src/fiscalpy.egg-info/SOURCES.txt +10 -0
- fiscalpy-0.0.1/src/fiscalpy.egg-info/dependency_links.txt +1 -0
- fiscalpy-0.0.1/src/fiscalpy.egg-info/top_level.txt +1 -0
- fiscalpy-0.0.1/tests/test_limpieza.py +0 -0
fiscalpy-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Carlos Ortiz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
fiscalpy-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fiscalpy
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Paquete del Observatorio
|
|
5
|
+
Author-email: Carlos Ortiz <cjortizb@javeriana.edu.co>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# FiscalPY
|
|
15
|
+
|
|
16
|
+
Fiscal utilities in python
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install fiscalpy
|
|
22
|
+
```
|
fiscalpy-0.0.1/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77.0.3"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "fiscalpy"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
description = "Paquete del Observatorio"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "Carlos Ortiz", email = "cjortizb@javeriana.edu.co" }
|
|
13
|
+
]
|
|
14
|
+
license = "MIT"
|
|
15
|
+
license-files = ["LICENSE"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Operating System :: OS Independent"
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[tool.setuptools.packages.find]
|
|
22
|
+
where = ["src"]
|
fiscalpy-0.0.1/setup.cfg
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def columnas_ingresos_territoriales(df):
|
|
6
|
+
lista_impuestos_muns = ['SOBRETASA AMBIENTAL', 'IMPUESTO PREDIAL UNIFICADO',
|
|
7
|
+
'SOBRETASA A LA GASOLINA', 'IMPUESTO DE INDUSTRIA Y COMERCIO',
|
|
8
|
+
'IMPUESTO COMPLEMENTARIO DE AVISOS Y TABLEROS',
|
|
9
|
+
'IMPUESTO DE DELINEACION', 'SOBRETASA BOMBERIL','IMPUESTO DE ALUMBRADO PUBLICO',
|
|
10
|
+
'TASA PRODEPORTE Y RECREACION', 'ESTAMPILLAS',
|
|
11
|
+
'IMPUESTO DE TRANSPORTE POR OLEODUCTOS Y GASODUCTOS',
|
|
12
|
+
'IMPUESTO SOBRE VEHICULOS AUTOMOTORES']
|
|
13
|
+
|
|
14
|
+
lista_impuestos_deptos = ['IMPUESTO SOBRE VEHICULOS AUTOMOTORES',
|
|
15
|
+
'IMPUESTO DE REGISTRO',
|
|
16
|
+
'IMPUESTO AL CONSUMO DE LICORES, VINOS, APERITIVOS Y SIMILARES',
|
|
17
|
+
'IMPUESTO AL CONSUMO DE CERVEZAS, SIFONES, REFAJOS Y MEZCLAS',
|
|
18
|
+
'IMPUESTO AL CONSUMO DE CIGARRILLOS Y TABACO',
|
|
19
|
+
'SOBRETASA A LA GASOLINA', 'TASA PRODEPORTE Y RECREACION',
|
|
20
|
+
'ESTAMPILLAS',
|
|
21
|
+
'SOBRETASA BOMBERIL']
|
|
22
|
+
|
|
23
|
+
lista_nt_muns = ['SISTEMA GENERAL DE PARTICIPACIONES', 'RECURSOS DEL SISTEMA DE SEGURIDAD SOCIAL INTEGRAL']
|
|
24
|
+
lista_nt_deptos = ['SISTEMA GENERAL DE PARTICIPACIONES','PARTICIPACION Y DERECHOS POR MONOPOLIO']
|
|
25
|
+
|
|
26
|
+
lista_cap_muns = ['RECURSOS DEL BALANCE','EXCEDENTES FINANCIEROS',
|
|
27
|
+
'DIVIDENDOS Y UTILIDADES POR OTRAS INVERSIONES DE CAPITAL']
|
|
28
|
+
lista_cap_deptos = ['RECURSOS DEL BALANCE', 'EXCEDENTES FINANCIEROS',
|
|
29
|
+
'DIVIDENDOS Y UTILIDADES POR OTRAS INVERSIONES DE CAPITAL']
|
|
30
|
+
|
|
31
|
+
def funcion_ofpuj1(row):
|
|
32
|
+
col_2 = row['col_2']
|
|
33
|
+
col_3 = row['col_3']
|
|
34
|
+
col_4 = row['col_4']
|
|
35
|
+
col_5 = row['col_5']
|
|
36
|
+
col_6 = row['col_6']
|
|
37
|
+
tipo_entidad = row['Tipo de Entidad']
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
if tipo_entidad == 'Municipio':
|
|
42
|
+
if col_3 == 'INGRESOS TRIBUTARIOS':
|
|
43
|
+
if col_5 in lista_impuestos_muns:
|
|
44
|
+
return col_5.capitalize()
|
|
45
|
+
else:
|
|
46
|
+
return "Otros ingresos tributarios"
|
|
47
|
+
elif col_3 == 'INGRESOS NO TRIBUTARIOS':
|
|
48
|
+
if col_5 in lista_nt_muns:
|
|
49
|
+
return col_5.capitalize()
|
|
50
|
+
elif col_4 in lista_nt_muns:
|
|
51
|
+
return col_4.capitalize()
|
|
52
|
+
else:
|
|
53
|
+
return "Otros ingresos no tributarios"
|
|
54
|
+
else:
|
|
55
|
+
if "RECURSOS DE CREDITO" in col_3:
|
|
56
|
+
return "Recursos de crédito"
|
|
57
|
+
elif col_3 in lista_cap_muns:
|
|
58
|
+
return col_3.capitalize()
|
|
59
|
+
else:
|
|
60
|
+
return "Otros recursos de capital"
|
|
61
|
+
|
|
62
|
+
else:
|
|
63
|
+
if col_3 == 'INGRESOS TRIBUTARIOS':
|
|
64
|
+
if col_5 in lista_impuestos_deptos:
|
|
65
|
+
return col_5.capitalize()
|
|
66
|
+
else:
|
|
67
|
+
return "Otros ingresos tributarios"
|
|
68
|
+
elif col_3 == 'INGRESOS NO TRIBUTARIOS':
|
|
69
|
+
if col_5 in lista_nt_deptos:
|
|
70
|
+
return col_5.capitalize()
|
|
71
|
+
elif col_4 in lista_nt_deptos:
|
|
72
|
+
return col_4.capitalize()
|
|
73
|
+
else:
|
|
74
|
+
return "Otros ingresos no tributarios"
|
|
75
|
+
else:
|
|
76
|
+
if "RECURSOS DE CREDITO" in col_3:
|
|
77
|
+
return "Recursos de crédito"
|
|
78
|
+
elif col_3 in lista_cap_deptos:
|
|
79
|
+
return col_3.capitalize()
|
|
80
|
+
else:
|
|
81
|
+
return "Otros recursos de capital"
|
|
82
|
+
|
|
83
|
+
lista_impuestos_muns = ['SOBRETASA AMBIENTAL',
|
|
84
|
+
'IMPUESTO PREDIAL UNIFICADO',
|
|
85
|
+
'SOBRETASA A LA GASOLINA',
|
|
86
|
+
'IMPUESTO DE INDUSTRIA Y COMERCIO',
|
|
87
|
+
'IMPUESTO COMPLEMENTARIO DE AVISOS Y TABLEROS',
|
|
88
|
+
'IMPUESTO DE DELINEACION',
|
|
89
|
+
'SOBRETASA BOMBERIL',
|
|
90
|
+
'IMPUESTO DE ALUMBRADO PUBLICO',
|
|
91
|
+
'TASA PRODEPORTE Y RECREACION',
|
|
92
|
+
'ESTAMPILLAS',
|
|
93
|
+
'IMPUESTO DE TRANSPORTE POR OLEODUCTOS Y GASODUCTOS',
|
|
94
|
+
'IMPUESTO SOBRE VEHICULOS AUTOMOTORES',
|
|
95
|
+
'IMPUESTO AL CONSUMO DE LICORES, VINOS, APERITIVOS Y SIMILARES',
|
|
96
|
+
'IMPUESTO AL CONSUMO DE CERVEZAS, SIFONES, REFAJOS Y MEZCLAS',
|
|
97
|
+
'IMPUESTO AL CONSUMO DE CIGARRILLOS Y TABACO',
|
|
98
|
+
'AVISOS Y TABLEROS',
|
|
99
|
+
'IMPUESTO AL CONSUMO CERVEZA',
|
|
100
|
+
'IMPUESTO DE DELINEACIÓN']
|
|
101
|
+
|
|
102
|
+
lista_impuestos_deptos = ['IMPUESTO SOBRE VEHICULOS AUTOMOTORES',
|
|
103
|
+
'IMPUESTO DE ALUMBRADO PUBLICO',
|
|
104
|
+
'IMPUESTO DE REGISTRO',
|
|
105
|
+
'IMPUESTO AL CONSUMO DE LICORES, VINOS, APERITIVOS Y SIMILARES',
|
|
106
|
+
'IMPUESTO AL CONSUMO DE CERVEZAS, SIFONES, REFAJOS Y MEZCLAS',
|
|
107
|
+
'IMPUESTO AL CONSUMO DE CIGARRILLOS Y TABACO',
|
|
108
|
+
'SOBRETASA A LA GASOLINA',
|
|
109
|
+
'TASA PRODEPORTE Y RECREACION',
|
|
110
|
+
'ESTAMPILLAS',
|
|
111
|
+
'SOBRETASA BOMBERIL',
|
|
112
|
+
'IMPUESTO PREDIAL UNIFICADO',
|
|
113
|
+
'IMPUESTO DE INDUSTRIA Y COMERCIO',
|
|
114
|
+
'IMPUESTO COMPLEMENTARIO DE AVISOS Y TABLEROS',]
|
|
115
|
+
|
|
116
|
+
taxes = list(set(lista_impuestos_deptos + lista_impuestos_muns))
|
|
117
|
+
|
|
118
|
+
lista_nt_muns = ['SISTEMA GENERAL DE PARTICIPACIONES', 'RECURSOS DEL SISTEMA DE SEGURIDAD SOCIAL INTEGRAL']
|
|
119
|
+
lista_nt_deptos = ['SISTEMA GENERAL DE PARTICIPACIONES','PARTICIPACION Y DERECHOS POR MONOPOLIO']
|
|
120
|
+
|
|
121
|
+
lista_cap_muns = ['RECURSOS DEL BALANCE',
|
|
122
|
+
'EXCEDENTES FINANCIEROS',
|
|
123
|
+
'DIVIDENDOS Y UTILIDADES POR OTRAS INVERSIONES DE CAPITAL',
|
|
124
|
+
'UTILIDADES Y EXCEDENTES FINANCIEROS (EMPRESAS INDUSTRIALES, COMERCIALES Y ESTABLECIMIENTOS PÚBLICOS)']
|
|
125
|
+
|
|
126
|
+
lista_rec = ['RECURSOS DEL CRÉDITO',
|
|
127
|
+
'RECURSOS DE CREDITO INTERNO',
|
|
128
|
+
'RECURSOS DE CREDITO EXTERNO']
|
|
129
|
+
SGP = ['SGP: LIBRE DESTINACIÓN DE PARTICIPACIÓN DE PROPÓSITO GENERAL MUNICIPIOS CATEGORÍAS 4, 5 Y 6',
|
|
130
|
+
'SISTEMA GENERAL DE PARTICIPACIONES',
|
|
131
|
+
]
|
|
132
|
+
|
|
133
|
+
def funcion_ofpuj2(row):
|
|
134
|
+
col2 = row['col_2']
|
|
135
|
+
col3 = row['col_3']
|
|
136
|
+
col4 = row['col_4']
|
|
137
|
+
col5 = row['col_5']
|
|
138
|
+
col7 = row['col_7']
|
|
139
|
+
|
|
140
|
+
if col3 == 'INGRESOS TRIBUTARIOS':
|
|
141
|
+
if col5 in taxes:
|
|
142
|
+
return col5.capitalize()
|
|
143
|
+
else:
|
|
144
|
+
return "Otros ingresos tributarios"
|
|
145
|
+
elif col3 == 'INGRESOS NO TRIBUTARIOS':
|
|
146
|
+
if col4 in ['TRANSFERENCIAS', 'TRANSFERENCIAS CORRIENTES']:
|
|
147
|
+
if col7 in SGP:
|
|
148
|
+
return "Sistema general de participaciones"
|
|
149
|
+
elif col7 == 'FONDO DE SOLIDARIDAD Y GARANTÍAS -FOSYGA-':
|
|
150
|
+
return "FOSYGA"
|
|
151
|
+
elif col5 in ['SISTEMA GENERAL DE PARTICIPACIONES', 'RECURSOS DEL SISTEMA DE SEGURIDAD SOCIAL INTEGRAL']:
|
|
152
|
+
return col5.capitalize()
|
|
153
|
+
else:
|
|
154
|
+
return "Otras transferencias"
|
|
155
|
+
elif col4 in ['PARTICIPACION Y DERECHOS POR MONOPOLIO', 'PARTICIPACIÓN Y DERECHOS POR MONOPOLIO']:
|
|
156
|
+
return "Participación y derechos por monopolio"
|
|
157
|
+
else:
|
|
158
|
+
return "Tasas, multas y contribuciones"
|
|
159
|
+
elif col2 == 'RECURSOS DE CAPITAL':
|
|
160
|
+
if col3 in lista_rec:
|
|
161
|
+
return "Recursos de crédito"
|
|
162
|
+
elif col3 in lista_cap_muns:
|
|
163
|
+
return col3.capitalize()
|
|
164
|
+
else:
|
|
165
|
+
return "Otros recursos de capital"
|
|
166
|
+
else:
|
|
167
|
+
return "Error en clasificación"
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def funcion_clas_gen1(row):
|
|
171
|
+
col_2 = row['col_2']
|
|
172
|
+
col_3 = row['col_3']
|
|
173
|
+
col_5 = row['col_5']
|
|
174
|
+
|
|
175
|
+
if col_2 == 'RECURSOS DE CAPITAL':
|
|
176
|
+
return col_2.capitalize()
|
|
177
|
+
elif col_3 == 'INGRESOS TRIBUTARIOS':
|
|
178
|
+
return col_3.capitalize()
|
|
179
|
+
elif col_5 == 'SISTEMA GENERAL DE PARTICIPACIONES':
|
|
180
|
+
return col_5.capitalize()
|
|
181
|
+
return "INGRESOS NO TRIBUTARIOS".capitalize()
|
|
182
|
+
|
|
183
|
+
def funcion_clas_gen2(row):
|
|
184
|
+
col2 = row['col_2']
|
|
185
|
+
col3 = row['col_3']
|
|
186
|
+
col4 = row['col_4']
|
|
187
|
+
if col2 == 'RECURSOS DE CAPITAL':
|
|
188
|
+
return col2.capitalize()
|
|
189
|
+
elif col3 == 'INGRESOS TRIBUTARIOS':
|
|
190
|
+
return "Recursos propios"
|
|
191
|
+
elif col4 in ['TRANSFERENCIAS', 'TRANSFERENCIAS CORRIENTES']:
|
|
192
|
+
return "Transferencias"
|
|
193
|
+
else:
|
|
194
|
+
return "Recursos propios"
|
|
195
|
+
df['clas_ofpuj'] = df.apply(funcion_ofpuj2, axis=1)
|
|
196
|
+
df['clas_gen1'] = df.apply(funcion_clas_gen1, axis=1)
|
|
197
|
+
df['clas_gen2'] = df.apply(funcion_clas_gen2, axis=1)
|
|
198
|
+
return df
|
|
199
|
+
|
|
200
|
+
def limpieza_ingresos_territoriales(df):
|
|
201
|
+
df2 = df.copy()
|
|
202
|
+
df2 = df2.rename(columns={'CodigoConcepto':'Código Concepto',
|
|
203
|
+
'Nombre': 'Concepto'})
|
|
204
|
+
|
|
205
|
+
df2['Código Concepto'] = df2['Código Concepto'].astype(str).str.strip()
|
|
206
|
+
df2['Concepto'] = df2['Concepto'].str.strip()
|
|
207
|
+
dictio_con = dict(df2[['Código Concepto', 'Concepto']].set_index('Código Concepto').to_records())
|
|
208
|
+
|
|
209
|
+
max_cols = df2['Código Concepto'].str.split('.').map(len).max()
|
|
210
|
+
|
|
211
|
+
for i in range(1, max_cols + 1):
|
|
212
|
+
df2[f'col_{i}'] = np.nan
|
|
213
|
+
|
|
214
|
+
# crear una columna con splits del código de concepto (lista de números)
|
|
215
|
+
df2['split'] = df2['Código Concepto'].str.split('.')
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
for idx, row in df2.iterrows():
|
|
219
|
+
split = row['split']
|
|
220
|
+
n = len(split)
|
|
221
|
+
for i in range(1, n + 1):
|
|
222
|
+
df2.loc[idx, f'col_{i}'] = dictio_con['.'.join(split[:i])]
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
df2["lists_tuple"] = df2["split"].apply(tuple)
|
|
226
|
+
|
|
227
|
+
sorted_tuples = sorted(df2["lists_tuple"].unique(), key=lambda x: (len(x), x))
|
|
228
|
+
|
|
229
|
+
relation = {}
|
|
230
|
+
|
|
231
|
+
for i, current_tuple in enumerate(sorted_tuples):
|
|
232
|
+
is_father = False
|
|
233
|
+
for other_tuple in sorted_tuples[i + 1:]:
|
|
234
|
+
|
|
235
|
+
if len(other_tuple) <= len(current_tuple) or not other_tuple[:len(current_tuple)] == current_tuple:
|
|
236
|
+
continue
|
|
237
|
+
|
|
238
|
+
is_father = True
|
|
239
|
+
break
|
|
240
|
+
|
|
241
|
+
relation[current_tuple] = "father" if is_father else "son"
|
|
242
|
+
|
|
243
|
+
def funcion2(row):
|
|
244
|
+
return relation[row['lists_tuple']]
|
|
245
|
+
df2['example'] = df2.apply(funcion2, axis=1)
|
|
246
|
+
sons = df2[df2['example'] == 'son']
|
|
247
|
+
sons = sons.drop(columns=['split', 'lists_tuple', 'example']).reset_index(drop=True)
|
|
248
|
+
sons[[f"col_{i}" for i in range(1, max_cols + 1)]] = sons[[f"col_{i}" for i in range(1, max_cols + 1)]].ffill(axis=1)
|
|
249
|
+
data_ready = sons.groupby(['Año Vigencia',
|
|
250
|
+
'Código DANE', 'Entidad', 'Tipo de Entidad',
|
|
251
|
+
'Departamento', 'col_1', 'col_2', 'col_3', 'col_4', 'col_5',
|
|
252
|
+
'col_6','col_7', 'col_8', 'col_9', 'col_10'])['Total Recaudo'].sum().reset_index()
|
|
253
|
+
return data_ready
|
|
254
|
+
|
|
255
|
+
def limpieza_gastos_territoriales(df):
|
|
256
|
+
df2 = df.copy()
|
|
257
|
+
|
|
258
|
+
df2['Código Concepto'] = df2['Código Concepto'].astype(str).str.strip()
|
|
259
|
+
df2['Concepto'] = df2['Concepto'].str.strip()
|
|
260
|
+
dictio_con = dict(df2[['Código Concepto', 'Concepto']].set_index('Código Concepto').to_records())
|
|
261
|
+
|
|
262
|
+
max_cols = df2['Código Concepto'].str.split('.').map(len).max()
|
|
263
|
+
|
|
264
|
+
for i in range(1, max_cols + 1):
|
|
265
|
+
df2[f'col_{i}'] = np.nan
|
|
266
|
+
|
|
267
|
+
# crear una columna con splits del código de concepto (lista de números)
|
|
268
|
+
df2['split'] = df2['Código Concepto'].str.split('.')
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
for idx, row in df2.iterrows():
|
|
272
|
+
split = row['split']
|
|
273
|
+
n = len(split)
|
|
274
|
+
for i in range(1, n + 1):
|
|
275
|
+
df2.loc[idx, f'col_{i}'] = dictio_con['.'.join(split[:i])]
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
df2["lists_tuple"] = df2["split"].apply(tuple)
|
|
279
|
+
|
|
280
|
+
sorted_tuples = sorted(df2["lists_tuple"].unique(), key=lambda x: (len(x), x))
|
|
281
|
+
|
|
282
|
+
relation = {}
|
|
283
|
+
for i, current_tuple in enumerate(sorted_tuples):
|
|
284
|
+
is_father = False
|
|
285
|
+
for other_tuple in sorted_tuples[i + 1:]:
|
|
286
|
+
|
|
287
|
+
if len(other_tuple) <= len(current_tuple) or not other_tuple[:len(current_tuple)] == current_tuple:
|
|
288
|
+
continue
|
|
289
|
+
|
|
290
|
+
is_father = True
|
|
291
|
+
break
|
|
292
|
+
|
|
293
|
+
relation[current_tuple] = "father" if is_father else "son"
|
|
294
|
+
|
|
295
|
+
def funcion2(row):
|
|
296
|
+
return relation[row['lists_tuple']]
|
|
297
|
+
df2['example'] = df2.apply(funcion2, axis=1)
|
|
298
|
+
sons = df2[df2['example'] == 'son']
|
|
299
|
+
|
|
300
|
+
sons[['col_1', 'col_2', 'col_3', 'col_4', 'col_5', 'col_6',
|
|
301
|
+
'col_7', 'col_8', 'col_9', 'col_10']] = sons[['col_1', 'col_2', 'col_3', 'col_4', 'col_5', 'col_6',
|
|
302
|
+
'col_7', 'col_8', 'col_9', 'col_10']].ffill(axis=1)
|
|
303
|
+
sons.drop(columns=['split', 'lists_tuple', 'example'], inplace=True)
|
|
304
|
+
sons.reset_index(drop=True, inplace=True)
|
|
305
|
+
|
|
306
|
+
sons = sons.groupby(['Año Vigencia', 'Código DANE', 'Entidad', 'Tipo de Entidad',
|
|
307
|
+
'Departamento', 'Region', 'Código Concepto', 'Concepto',
|
|
308
|
+
'Código Vigencia del Gasto', 'Vigencia del Gasto',
|
|
309
|
+
'Código Sección Presupuestal', 'Sección Presupuestal', 'col_1', 'col_2', 'col_3', 'col_4', 'col_5',
|
|
310
|
+
'col_6', 'col_7', 'col_8', 'col_9', 'col_10'])[['Compromisos', 'Obligaciones', 'Pagos']].sum().reset_index()
|
|
311
|
+
|
|
312
|
+
return sons
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fiscalpy
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Paquete del Observatorio
|
|
5
|
+
Author-email: Carlos Ortiz <cjortizb@javeriana.edu.co>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# FiscalPY
|
|
15
|
+
|
|
16
|
+
Fiscal utilities in python
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install fiscalpy
|
|
22
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/fiscalpy/__init__.py
|
|
5
|
+
src/fiscalpy/limpieza.py
|
|
6
|
+
src/fiscalpy.egg-info/PKG-INFO
|
|
7
|
+
src/fiscalpy.egg-info/SOURCES.txt
|
|
8
|
+
src/fiscalpy.egg-info/dependency_links.txt
|
|
9
|
+
src/fiscalpy.egg-info/top_level.txt
|
|
10
|
+
tests/test_limpieza.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fiscalpy
|
|
File without changes
|