|
2 | 2 | Schedule A, Contributions
|
3 | 3 | Hopefully this can be joined with other Schedule classes into a single Transaction class
|
4 | 4 | """
|
5 |
| -import pandas as pd |
6 |
| -from sqlalchemy.types import BOOLEAN, DATE, DOUBLE_PRECISION, INTEGER, TIME, VARCHAR |
7 |
| -from .base import BaseModel |
| 5 | +from .committee import Committees |
| 6 | +from .filing import Filings |
| 7 | +from .transaction import Transactions |
| 8 | +from .schedule import ScheduleBase |
8 | 9 |
|
9 |
| -class A_Contributions(BaseModel): |
| 10 | +class A_Contributions(ScheduleBase): |
10 | 11 | """
|
11 | 12 | Each record represents Schedule A - Contributions from form 460
|
12 | 13 | """
|
13 | 14 | def __init__(
|
14 | 15 | self,
|
15 |
| - transactions:pd.DataFrame, |
16 |
| - filings:pd.DataFrame, |
17 |
| - committees:pd.DataFrame |
| 16 | + transactions:Transactions, |
| 17 | + filings:Filings, |
| 18 | + committees:Committees |
18 | 19 | ):
|
19 |
| - f460a_trans = transactions.loc[transactions['cal_tran_type'] == 'F460A'].drop( |
20 |
| - columns=['cal_tran_type'] |
| 20 | + self._form_id = 'F460A' |
| 21 | + super().__init__( |
| 22 | + self._form_id, |
| 23 | + transactions, |
| 24 | + filings, |
| 25 | + committees |
21 | 26 | )
|
22 |
| - |
23 |
| - unique_committees = committees.groupby(['Filer_ID'], as_index=False).first()[ |
24 |
| - ['filer_nid','Filer_ID','Filer_NamL','_Committee_Type'] |
25 |
| - ] |
26 |
| - |
27 |
| - committee_filings = unique_committees.merge(filings, on='filer_nid', how='left').drop( |
28 |
| - columns=['filer_nid'] |
29 |
| - ).rename( |
30 |
| - columns={ |
31 |
| - 'RptNum': 'Report_Num', |
32 |
| - '_Committee_Type': 'Committee_Type' |
33 |
| - } |
34 |
| - ) |
35 |
| - |
36 |
| - committees_sans_filings = committee_filings[committee_filings['filing_nid'].isna()] |
37 |
| - |
38 |
| - f460a = committee_filings.merge(f460a_trans, |
39 |
| - how='inner', |
40 |
| - on='filing_nid' |
41 |
| - ).drop( |
42 |
| - columns=['filing_nid'] |
43 |
| - ) |
44 |
| - |
45 |
| - f460a[['Form_Type','tblCover_Offic_Dscr','tblCover_Office_Cd']] = ['00:00:00', '', ''] |
46 |
| - |
47 |
| - super().__init__(f460a) |
48 |
| - |
49 |
| - self._dtypes = { |
50 |
| - 'Filer_ID': 'string', |
51 |
| - 'Filer_NamL': 'string', |
52 |
| - 'Report_Num': 'Int64', |
53 |
| - 'Committee_Type': 'string', |
54 |
| - 'Rpt_Date': 'string', |
55 |
| - 'From_Date': 'string', |
56 |
| - 'Thru_Date': 'string', |
57 |
| - 'Elect_Date': 'string', |
58 |
| - 'tblCover_Office_Cd': 'string', |
59 |
| - 'tblCover_Offic_Dscr': 'string', |
60 |
| - 'Rec_Type': 'string', |
61 |
| - 'Form_Type': 'string', |
62 |
| - 'Tran_ID': 'string', |
63 |
| - 'Entity_Cd': 'string', |
64 |
| - 'Tran_NamL': 'string', |
65 |
| - 'Tran_NamF': 'string', |
66 |
| - 'Tran_NamT': 'string', |
67 |
| - 'Tran_NamS': 'string', |
68 |
| - 'Tran_Adr1': 'string', |
69 |
| - 'Tran_Adr2': 'string', |
70 |
| - 'Tran_City': 'string', |
71 |
| - 'Tran_State': 'string', |
72 |
| - 'Tran_Zip4': 'string', |
73 |
| - 'Tran_Emp': 'string', |
74 |
| - 'Tran_Occ': 'string', |
75 |
| - 'Tran_Self': bool, |
76 |
| - 'Tran_Type': 'string', |
77 |
| - 'Tran_Date': 'string', |
78 |
| - 'Tran_Date1': 'string', |
79 |
| - 'Tran_Amt1': float, |
80 |
| - 'Tran_Amt2': float, |
81 |
| - 'Tran_Dscr': 'string', |
82 |
| - 'Cmte_ID': 'string', |
83 |
| - 'Tres_NamL': 'string', |
84 |
| - 'Tres_NamF': 'string', |
85 |
| - 'Tres_NamT': 'string', |
86 |
| - 'Tres_NamS': 'string', |
87 |
| - 'Tres_Adr1': 'string', |
88 |
| - 'Tres_Adr2': 'string', |
89 |
| - 'Tres_City': 'string', |
90 |
| - 'Tres_State': 'string', |
91 |
| - 'Tres_Zip': 'string', |
92 |
| - 'Intr_NamL': 'string', |
93 |
| - 'Intr_NamF': 'string', |
94 |
| - 'Intr_NamT': 'string', |
95 |
| - 'Intr_NamS': 'string', |
96 |
| - 'Intr_Adr1': 'string', |
97 |
| - 'Intr_Adr2': 'string', |
98 |
| - 'Intr_City': 'string', |
99 |
| - 'Intr_State': 'string', |
100 |
| - 'Intr_Zip4': 'string', |
101 |
| - 'Intr_Emp': 'string', |
102 |
| - 'Intr_Occ': 'string', |
103 |
| - 'Intr_Self': bool, |
104 |
| - 'Cand_NamL': 'string', |
105 |
| - 'Cand_NamF': 'string', |
106 |
| - 'Cand_NamT': 'string', |
107 |
| - 'Cand_NamS': 'string', |
108 |
| - 'tblDetlTran_Office_Cd': 'string', |
109 |
| - 'tblDetlTran_Offic_Dscr': 'string', |
110 |
| - 'Juris_Cd': 'string', |
111 |
| - 'Juris_Dscr': 'string', |
112 |
| - 'Dist_No': 'string', |
113 |
| - 'Off_S_H_Cd': 'string', |
114 |
| - 'Bal_Name': 'string', |
115 |
| - 'Bal_Num': 'string', |
116 |
| - 'Bal_Juris': 'string', |
117 |
| - 'Sup_Opp_Cd': 'string', |
118 |
| - 'Memo_Code': 'string', |
119 |
| - 'Memo_RefNo': 'string', |
120 |
| - 'BakRef_TID': 'string', |
121 |
| - 'XRef_SchNm': 'string', |
122 |
| - 'XRef_Match': 'string', |
123 |
| - 'Loan_Rate': 'string', |
124 |
| - 'Int_CmteId': 'Int64' |
125 |
| - } |
126 |
| - self._sql_dtypes = { |
127 |
| - 'Filer_ID': VARCHAR(9), |
128 |
| - 'Filer_NamL': VARCHAR(183), |
129 |
| - 'Report_Num': INTEGER, |
130 |
| - 'Committee_Type': VARCHAR(64), |
131 |
| - 'Rpt_Date': DATE, |
132 |
| - 'From_Date': DATE, |
133 |
| - 'Thru_Date': DATE, |
134 |
| - 'Elect_Date': DATE, |
135 |
| - 'tblCover_Office_Cd': VARCHAR(64), |
136 |
| - 'tblCover_Offic_Dscr': VARCHAR(64), |
137 |
| - 'Rec_Type': VARCHAR(4), |
138 |
| - 'Form_Type': TIME, |
139 |
| - 'Tran_ID': VARCHAR(12), |
140 |
| - 'Entity_Cd': VARCHAR(3), |
141 |
| - 'Tran_NamL': VARCHAR(199), |
142 |
| - 'Tran_NamF': VARCHAR(38), |
143 |
| - 'Tran_NamT': VARCHAR(6), |
144 |
| - 'Tran_NamS': VARCHAR(5), |
145 |
| - 'Tran_Adr1': VARCHAR(64), |
146 |
| - 'Tran_Adr2': VARCHAR(64), |
147 |
| - 'Tran_City': VARCHAR(50), |
148 |
| - 'Tran_State': VARCHAR(4), |
149 |
| - 'Tran_Zip4': VARCHAR(10), |
150 |
| - 'Tran_Emp': VARCHAR(92), |
151 |
| - 'Tran_Occ': VARCHAR(60), |
152 |
| - 'Tran_Self': BOOLEAN, |
153 |
| - 'Tran_Type': VARCHAR(4), |
154 |
| - 'Tran_Date': DATE, |
155 |
| - 'Tran_Date1': DATE, |
156 |
| - 'Tran_Amt1': DOUBLE_PRECISION, |
157 |
| - 'Tran_Amt2': DOUBLE_PRECISION, |
158 |
| - 'Tran_Dscr': VARCHAR(56), |
159 |
| - 'Cmte_ID': VARCHAR(9), |
160 |
| - 'Tres_NamL': VARCHAR(4), |
161 |
| - 'Tres_NamF': VARCHAR(4), |
162 |
| - 'Tres_NamT': VARCHAR(64), |
163 |
| - 'Tres_NamS': VARCHAR(64), |
164 |
| - 'Tres_Adr1': VARCHAR(64), |
165 |
| - 'Tres_Adr2': VARCHAR(64), |
166 |
| - 'Tres_City': VARCHAR(7), |
167 |
| - 'Tres_State': VARCHAR(4), |
168 |
| - 'Tres_Zip': INTEGER, |
169 |
| - 'Intr_NamL': VARCHAR(74), |
170 |
| - 'Intr_NamF': VARCHAR(6), |
171 |
| - 'Intr_NamT': VARCHAR(64), |
172 |
| - 'Intr_NamS': VARCHAR(64), |
173 |
| - 'Intr_Adr1': VARCHAR(64), |
174 |
| - 'Intr_Adr2': VARCHAR(64), |
175 |
| - 'Intr_City': VARCHAR(13), |
176 |
| - 'Intr_State': VARCHAR(4), |
177 |
| - 'Intr_Zip4': VARCHAR(10), |
178 |
| - 'Intr_Emp': VARCHAR(15), |
179 |
| - 'Intr_Occ': VARCHAR(8), |
180 |
| - 'Intr_Self': BOOLEAN, |
181 |
| - 'Cand_NamL': VARCHAR(64), |
182 |
| - 'Cand_NamF': VARCHAR(64), |
183 |
| - 'Cand_NamT': VARCHAR(64), |
184 |
| - 'Cand_NamS': VARCHAR(64), |
185 |
| - 'tblDetlTran_Office_Cd': VARCHAR(4), |
186 |
| - 'tblDetlTran_Offic_Dscr': VARCHAR(19), |
187 |
| - 'Juris_Cd': VARCHAR(4), |
188 |
| - 'Juris_Dscr': VARCHAR(64), |
189 |
| - 'Dist_No': VARCHAR(64), |
190 |
| - 'Off_S_H_Cd': VARCHAR(64), |
191 |
| - 'Bal_Name': VARCHAR(64), |
192 |
| - 'Bal_Num': VARCHAR(4), |
193 |
| - 'Bal_Juris': VARCHAR(64), |
194 |
| - 'Sup_Opp_Cd': VARCHAR(64), |
195 |
| - 'Memo_Code': VARCHAR(64), |
196 |
| - 'Memo_RefNo': VARCHAR(11), |
197 |
| - 'BakRef_TID': VARCHAR(64), |
198 |
| - 'XRef_SchNm': VARCHAR(64), |
199 |
| - 'XRef_Match': VARCHAR(64), |
200 |
| - 'Loan_Rate': VARCHAR(64), |
201 |
| - 'Int_CmteId': INTEGER |
202 |
| - } |
203 |
| - self._sql_cols = list(self._sql_dtypes.keys()) |
204 |
| - self._sql_table_name = 'A-Contributions' |
0 commit comments