Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

transformdata.py 3.5 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
  1. import pandas as pd
  2. import numpy as np
  3. from datetime import datetime
  4. from datetime import timedelta
  5. def fechas_cambiadas(row):
  6. if row['DURACION CAUSA'] < 0:
  7. fecha_inicio = row['FECHA TERMINO']
  8. fecha_termino = row['FECHA INGRESO']
  9. row['FECHA INGRESO'] = fecha_termino
  10. row['FECHA TERMINO'] = fecha_inicio
  11. row['DURACION CAUSA'] = row['DURACION CAUSA']*-1
  12. return row
  13. def fecha_programada(row):
  14. if row['FECHA PROGRAMACION AUDIENCIA'] is pd.NaT:
  15. row['FECHA PROGRAMACION AUDIENCIA'] = row['FECHA AUDIENCIA'] - pd.tseries.offsets.Day(row['DIAS AGENDAMIENTO'])
  16. return row
  17. def faltantes_materia(row):
  18. # Caso Causas con INGRESO pero sin TERMINO aún
  19. if pd.notnull(row['FECHA INGRESO_x']) and pd.isnull(row['FECHA INGRESO_y']):
  20. row['FECHA INGRESO_y'] = row['FECHA INGRESO_x']
  21. row['MATERIA_y'] = row['MATERIA_x']
  22. row['COD. CORTE_y'] = row['COD. CORTE_x']
  23. row['CORTE_y'] = row['CORTE_x']
  24. row['TRIBUNAL_y'] = row['TRIBUNAL_x']
  25. row['CORTE_y'] = row['CORTE_x']
  26. row['TIPO CAUSA_y'] = row['TIPO CAUSA_x']
  27. row['MOTIVO TERMINO'] = 'SIN TERMINO'
  28. # Caso Causas sin INGRESO pero que los datos estan con TERMINO
  29. if pd.isnull(row['FECHA INGRESO_x']) and pd.notnull(row['FECHA INGRESO_y']):
  30. row['FECHA INGRESO_x'] = row['FECHA INGRESO_y']
  31. row['MATERIA_x'] = row['MATERIA_y']
  32. row['COD. CORTE_x'] = row['COD. CORTE_y']
  33. row['CORTE_x'] = row['CORTE_y']
  34. row['TRIBUNAL_x'] = row['TRIBUNAL_y']
  35. row['CORTE_x'] = row['CORTE_y']
  36. row['TIPO CAUSA_x'] = row['TIPO CAUSA_y']
  37. #row['MES INGRESO'] = int(row['FECHA INGRESO_y'].strftime("%m"))
  38. row['AÑO INGRESO'] = int(row['FECHA INGRESO_y'].strftime("%Y"))
  39. row['MOTIVO TERMINO'] = str(row['MOTIVO TERMINO']).replace(".","")
  40. # Caso Causas con ingreso y termino
  41. if pd.notnull(row['FECHA INGRESO_x']) and pd.notnull(row['FECHA INGRESO_y']):
  42. row['MOTIVO TERMINO'] = str(row['MOTIVO TERMINO']).replace(".","")
  43. return row
  44. def faltantes_rol(row):
  45. # Caso Causas con INGRESO pero sin TERMINO aún
  46. if pd.notnull(row['FECHA INGRESO_x']) and pd.isnull(row['FECHA INGRESO_y']):
  47. row['FECHA INGRESO_y'] = row['FECHA INGRESO_x']
  48. row['COD. CORTE_y'] = row['COD. CORTE_x']
  49. row['CORTE_y'] = row['CORTE_x']
  50. row['TRIBUNAL_y'] = row['TRIBUNAL_x']
  51. row['CORTE_y'] = row['CORTE_x']
  52. row['TIPO CAUSA_y'] = row['TIPO CAUSA_x']
  53. row['MOTIVO TERMINO'] = 'SIN TERMINO'
  54. # Caso Causas sin INGRESO pero que los datos estan con TERMINO
  55. if pd.isnull(row['FECHA INGRESO_x']) and pd.notnull(row['FECHA INGRESO_y']):
  56. row['FECHA INGRESO_x'] = row['FECHA INGRESO_y']
  57. row['COD. CORTE_x'] = row['COD. CORTE_y']
  58. row['CORTE_x'] = row['CORTE_y']
  59. row['TRIBUNAL_x'] = row['TRIBUNAL_y']
  60. row['CORTE_x'] = row['CORTE_y']
  61. row['TIPO CAUSA_x'] = row['TIPO CAUSA_y']
  62. row['AÑO INGRESO'] = int(row['FECHA INGRESO_y'].strftime("%Y"))
  63. row['MOTIVO TERMINO'] = str(row['MOTIVO TERMINO']).replace(".","")
  64. # Caso Causas con ingreso y termino
  65. if pd.notnull(row['FECHA INGRESO_x']) and pd.notnull(row['FECHA INGRESO_y']):
  66. row['MOTIVO TERMINO'] = str(row['MOTIVO TERMINO']).replace(".","")
  67. return row
  68. def crea_rit(row):
  69. row['TRIBUNAL_RIT'] = str(row['COD. TRIBUNAL']) + "-" + row['RIT']
  70. return row
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...