|
2 | 2 | import pandas as pd |
3 | 3 |
|
4 | 4 | NON_PERFORMING_LOANS_BY_REGION_PF = { |
5 | | - "N": "", |
| 5 | + "N": "15888", |
6 | 6 | "NE": "", |
7 | 7 | "CO": "", |
8 | 8 | "SE": "", |
|
30 | 30 | "RJ": "", |
31 | 31 | "RN": "", |
32 | 32 | "RS": "", |
33 | | - "RO": "", |
34 | | - "RR": "", |
| 33 | + "RO": "15882", |
| 34 | + "RR": "15883", |
35 | 35 | "SC": "", |
36 | 36 | "SP": "", |
37 | 37 | "SE": "", |
38 | | - "TO": "", |
| 38 | + "TO": "15887", |
39 | 39 | } |
40 | 40 | NON_PERFORMING_LOANS_BY_REGION_PJ = { |
41 | | - "N": "", |
| 41 | + "N": "15920", |
42 | 42 | "NE": "", |
43 | 43 | "CO": "", |
44 | 44 | "SE": "", |
45 | 45 | "S": "", |
46 | 46 | } |
47 | 47 | NON_PERFORMING_LOANS_BY_STATE_PJ = { |
48 | | - "AC": "15861", |
| 48 | + "AC": "15893", |
49 | 49 | "AL": "", |
50 | | - "AP": "15863", |
51 | | - "AM": "15864", |
| 50 | + "AP": "15895", |
| 51 | + "AM": "15896", |
52 | 52 | "BA": "15865", |
53 | 53 | "CE": "", |
54 | 54 | "DF": "", |
|
58 | 58 | "MT": "", |
59 | 59 | "MS": "", |
60 | 60 | "MG": "", |
61 | | - "PA": "15874", |
| 61 | + "PA": "15906", |
62 | 62 | "PB": "", |
63 | 63 | "PR": "", |
64 | 64 | "PE": "", |
65 | 65 | "PI": "", |
66 | 66 | "RJ": "", |
67 | 67 | "RN": "", |
68 | 68 | "RS": "", |
69 | | - "RO": "", |
70 | | - "RR": "", |
| 69 | + "RO": "15914", |
| 70 | + "RR": "15915", |
71 | 71 | "SC": "", |
72 | 72 | "SP": "", |
73 | 73 | "SE": "", |
74 | | - "TO": "" |
| 74 | + "TO": "15919" |
75 | 75 | } |
76 | 76 | NON_PERFORMING_LOANS_BY_REGION_TOTAL = { |
77 | | - "N": "", |
| 77 | + "N": "15952", |
78 | 78 | "NE": "", |
79 | 79 | "CO": "", |
80 | 80 | "SE": "", |
81 | 81 | "S": "", |
82 | 82 | } |
83 | 83 | NON_PERFORMING_LOANS_BY_STATE_TOTAL = { |
84 | | - "AC": "15861", |
| 84 | + "AC": "15925", |
85 | 85 | "AL": "", |
86 | | - "AP": "15863", |
87 | | - "AM": "15864", |
| 86 | + "AP": "15927", |
| 87 | + "AM": "15928", |
88 | 88 | "BA": "15865", |
89 | 89 | "CE": "", |
90 | 90 | "DF": "", |
|
94 | 94 | "MT": "", |
95 | 95 | "MS": "", |
96 | 96 | "MG": "", |
97 | | - "PA": "15874", |
| 97 | + "PA": "15938", |
98 | 98 | "PB": "", |
99 | 99 | "PR": "", |
100 | 100 | "PE": "", |
101 | 101 | "PI": "", |
102 | 102 | "RJ": "", |
103 | 103 | "RN": "", |
104 | 104 | "RS": "", |
105 | | - "RO": "", |
106 | | - "RR": "", |
| 105 | + "RO": "15946", |
| 106 | + "RR": "15947", |
107 | 107 | "SC": "", |
108 | 108 | "SP": "", |
109 | 109 | "SE": "", |
110 | | - "TO": "" |
| 110 | + "TO": "15951" |
111 | 111 | } |
112 | 112 |
|
113 | 113 |
|
114 | 114 | def get_non_performing_loans_codes(states_or_region, mode="total"): |
115 | 115 | """SGS da Inadimplência das operações de crédito. |
116 | 116 |
|
117 | 117 | Pode ser total, pessoas físicas (PF) ou jurídicas (PJ).""" |
118 | | - non_performing_loans_by_state = NON_PERFORMING_LOANS_BY_STATE_TOTAL |
119 | | - non_performing_loans_by_region = NON_PERFORMING_LOANS_BY_REGION_TOTAL |
120 | | - |
121 | 118 | is_state = False |
122 | 119 | is_region = False |
123 | 120 | states_or_region = [states_or_region] if isinstance(states_or_region, str) else states_or_region |
124 | 121 | states_or_region = [location.upper() for location in states_or_region] |
125 | | - if any(location in list(non_performing_loans_by_state.keys()) for location in states_or_region): |
| 122 | + if any(location in list(NON_PERFORMING_LOANS_BY_STATE_TOTAL.keys()) for location in states_or_region): |
126 | 123 | is_state = True |
127 | | - elif any(location in list(non_performing_loans_by_region.keys()) for location in states_or_region): |
| 124 | + elif any(location in list(NON_PERFORMING_LOANS_BY_REGION_TOTAL.keys()) for location in states_or_region): |
128 | 125 | is_region = True |
129 | 126 |
|
130 | 127 | if not is_state and not is_region: |
131 | 128 | raise Exception(f"Not a valid state or region: {states_or_region}") |
132 | 129 |
|
133 | 130 | codes = [] |
| 131 | + non_performing_loans_by_location = NON_PERFORMING_LOANS_BY_STATE_TOTAL |
134 | 132 | if is_state: |
135 | 133 | if mode.upper() == "PF": |
136 | | - non_performing_loans_by_state = NON_PERFORMING_LOANS_BY_STATE_PF |
| 134 | + non_performing_loans_by_location = NON_PERFORMING_LOANS_BY_STATE_PF |
137 | 135 | elif mode.upper() == "PJ": |
138 | | - non_performing_loans_by_state = NON_PERFORMING_LOANS_BY_STATE_PJ |
| 136 | + non_performing_loans_by_location = NON_PERFORMING_LOANS_BY_STATE_PJ |
139 | 137 | elif is_region: |
| 138 | + non_performing_loans_by_location = NON_PERFORMING_LOANS_BY_REGION_TOTAL |
140 | 139 | if mode.upper() == "PF": |
141 | | - non_performing_loans_by_state = NON_PERFORMING_LOANS_BY_REGION_PF |
| 140 | + non_performing_loans_by_location = NON_PERFORMING_LOANS_BY_REGION_PF |
142 | 141 | elif mode.upper() == "PJ": |
143 | | - non_performing_loans_by_state = NON_PERFORMING_LOANS_BY_REGION_PJ |
| 142 | + non_performing_loans_by_location = NON_PERFORMING_LOANS_BY_REGION_PJ |
144 | 143 |
|
145 | 144 | for location in states_or_region: |
146 | | - codes.append(non_performing_loans_by_state.get(location)) |
| 145 | + codes.append(non_performing_loans_by_location[location]) |
147 | 146 | return codes |
148 | 147 |
|
149 | 148 |
|
|
0 commit comments