File size: 60,739 Bytes
e9e9f7f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>Title</th>\n",
       "      <th>BillNumber</th>\n",
       "      <th>DocketNumber</th>\n",
       "      <th>GeneralCourtNumber</th>\n",
       "      <th>PrimarySponsor</th>\n",
       "      <th>Cosponsors</th>\n",
       "      <th>JointSponsor</th>\n",
       "      <th>BillHistory</th>\n",
       "      <th>LegislationTypeName</th>\n",
       "      <th>Pinslip</th>\n",
       "      <th>DocumentText</th>\n",
       "      <th>EmergencyPreamble</th>\n",
       "      <th>RollCalls</th>\n",
       "      <th>Attachments</th>\n",
       "      <th>CommitteeRecommendations</th>\n",
       "      <th>Amendments</th>\n",
       "      <th>List References</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2299</td>\n",
       "      <td>An Act relative to collective bargaining right...</td>\n",
       "      <td>H3069</td>\n",
       "      <td>HD2435</td>\n",
       "      <td>193.0</td>\n",
       "      <td>{'Id': 'PJK1', 'Name': 'Patrick Joseph Kearney...</td>\n",
       "      <td>[{'Id': 'PJK1', 'Name': 'Patrick Joseph Kearne...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>http://malegislature.gov/api/GeneralCourts/193...</td>\n",
       "      <td>Bill</td>\n",
       "      <td>By Representative Kearney of Scituate, a petit...</td>\n",
       "      <td>\\tSECTION 1. Section 1 of Chapter 150E of the ...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[['1', '150E'], ['23', '268A']]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2358</td>\n",
       "      <td>An Act relative to the open meeting law</td>\n",
       "      <td>H3121</td>\n",
       "      <td>HD2204</td>\n",
       "      <td>193.0</td>\n",
       "      <td>{'Id': 'E_U1', 'Name': 'Erika Uyterhoeven', 'T...</td>\n",
       "      <td>[{'Id': 'E_U1', 'Name': 'Erika Uyterhoeven', '...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>http://malegislature.gov/api/GeneralCourts/193...</td>\n",
       "      <td>Bill</td>\n",
       "      <td>By Representative Uyterhoeven of Somerville, a...</td>\n",
       "      <td>\\tSECTION 18 of chapter 30A of the General Law...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[['18', '30A']]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0                                              Title BillNumber  \\\n",
       "0        2299  An Act relative to collective bargaining right...      H3069   \n",
       "1        2358            An Act relative to the open meeting law      H3121   \n",
       "\n",
       "  DocketNumber  GeneralCourtNumber  \\\n",
       "0       HD2435               193.0   \n",
       "1       HD2204               193.0   \n",
       "\n",
       "                                      PrimarySponsor  \\\n",
       "0  {'Id': 'PJK1', 'Name': 'Patrick Joseph Kearney...   \n",
       "1  {'Id': 'E_U1', 'Name': 'Erika Uyterhoeven', 'T...   \n",
       "\n",
       "                                          Cosponsors JointSponsor  \\\n",
       "0  [{'Id': 'PJK1', 'Name': 'Patrick Joseph Kearne...          NaN   \n",
       "1  [{'Id': 'E_U1', 'Name': 'Erika Uyterhoeven', '...          NaN   \n",
       "\n",
       "                                         BillHistory LegislationTypeName  \\\n",
       "0  http://malegislature.gov/api/GeneralCourts/193...                Bill   \n",
       "1  http://malegislature.gov/api/GeneralCourts/193...                Bill   \n",
       "\n",
       "                                             Pinslip  \\\n",
       "0  By Representative Kearney of Scituate, a petit...   \n",
       "1  By Representative Uyterhoeven of Somerville, a...   \n",
       "\n",
       "                                        DocumentText  EmergencyPreamble  \\\n",
       "0  \\tSECTION 1. Section 1 of Chapter 150E of the ...                NaN   \n",
       "1  \\tSECTION 18 of chapter 30A of the General Law...                NaN   \n",
       "\n",
       "  RollCalls Attachments CommitteeRecommendations Amendments  \\\n",
       "0        []          []                       []         []   \n",
       "1        []          []                       []         []   \n",
       "\n",
       "                   List References  \n",
       "0  [['1', '150E'], ['23', '268A']]  \n",
       "1                  [['18', '30A']]  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import requests\n",
    "import pandas as pd\n",
    "\n",
    "df = pd.read_csv(\"list_regex_format_12bills.csv\")\n",
    "df.head(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "List References: section number and chapter format"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0                       [['1', '150E'], ['23', '268A']]\n",
       "1                                       [['18', '30A']]\n",
       "2                                                   NaN\n",
       "3     [['2', '15D'], ['2', '18B'], ['11', '15D'], ['...\n",
       "4                                       [['10', '70B']]\n",
       "5                                        [['77', '54']]\n",
       "6                          [['1', '125'], ['73', '7C']]\n",
       "7                       [['1', '150E'], ['23', '268A']]\n",
       "8                [['7', '4'], ['7', '4'], ['10', '66']]\n",
       "9                                                   NaN\n",
       "10    [['2', '15D'], ['2', '18B'], ['11', '15D'], ['...\n",
       "11                                       [['77', '54']]\n",
       "Name: List References, dtype: object"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['List References'] "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "List References: section number and chapter format"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Title</th>\n",
       "      <th>BillNumber</th>\n",
       "      <th>DocketNumber</th>\n",
       "      <th>DocumentText</th>\n",
       "      <th>List References</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>An Act relative to collective bargaining right...</td>\n",
       "      <td>H3069</td>\n",
       "      <td>HD2435</td>\n",
       "      <td>\\tSECTION 1. Section 1 of Chapter 150E of the ...</td>\n",
       "      <td>[['1', '150E'], ['23', '268A']]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>An Act relative to the open meeting law</td>\n",
       "      <td>H3121</td>\n",
       "      <td>HD2204</td>\n",
       "      <td>\\tSECTION 18 of chapter 30A of the General Law...</td>\n",
       "      <td>[['18', '30A']]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>An Act relative to vehicle recalls</td>\n",
       "      <td>H400</td>\n",
       "      <td>HD1240</td>\n",
       "      <td>\\tSECTION 1. Chapter 90 of the General Laws, a...</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>An Act providing affordable and accessible hig...</td>\n",
       "      <td>H489</td>\n",
       "      <td>HD2794</td>\n",
       "      <td>\\tSECTION 1. The seventh paragraph of section ...</td>\n",
       "      <td>[['2', '15D'], ['2', '18B'], ['11', '15D'], ['...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>An Act to Improve access, opportunity, and cap...</td>\n",
       "      <td>H538</td>\n",
       "      <td>HD485</td>\n",
       "      <td>\\tSECTION 1. To create a new capital infrastru...</td>\n",
       "      <td>[['10', '70B']]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>An Act providing a local option for ranked cho...</td>\n",
       "      <td>H711</td>\n",
       "      <td>HD1183</td>\n",
       "      <td>\\tSECTION 1. Section 44A of chapter 43 of the ...</td>\n",
       "      <td>[['77', '54']]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>An Act establishing a jail and prison construc...</td>\n",
       "      <td>S1979</td>\n",
       "      <td>SD661</td>\n",
       "      <td>\\tSECTION 1. Chapter 7C of the General Laws is...</td>\n",
       "      <td>[['1', '125'], ['73', '7C']]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>An Act relative to collective bargaining right...</td>\n",
       "      <td>S2014</td>\n",
       "      <td>SD1208</td>\n",
       "      <td>\\tSECTION 1. Section 1 of chapter 150E of the ...</td>\n",
       "      <td>[['1', '150E'], ['23', '268A']]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>An Act extending the public records law to the...</td>\n",
       "      <td>S2064</td>\n",
       "      <td>SD390</td>\n",
       "      <td>\\tSECTION 1. Section 7 of chapter 4 of the Gen...</td>\n",
       "      <td>[['7', '4'], ['7', '4'], ['10', '66']]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>An Act to end discriminatory outcomes in vocat...</td>\n",
       "      <td>S257</td>\n",
       "      <td>SD2312</td>\n",
       "      <td>\\tSECTION 1. Chapter 74 of the General Laws is...</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>An Act providing affordable and accessible hig...</td>\n",
       "      <td>S301</td>\n",
       "      <td>SD667</td>\n",
       "      <td>\\tSECTION 1. The seventh paragraph of section ...</td>\n",
       "      <td>[['2', '15D'], ['2', '18B'], ['11', '15D'], ['...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>An Act providing a local option for ranked cho...</td>\n",
       "      <td>S433</td>\n",
       "      <td>SD391</td>\n",
       "      <td>\\tSECTION 1. Section 44A of chapter 43 of the ...</td>\n",
       "      <td>[['77', '54']]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                Title BillNumber DocketNumber  \\\n",
       "0   An Act relative to collective bargaining right...      H3069       HD2435   \n",
       "1             An Act relative to the open meeting law      H3121       HD2204   \n",
       "2                  An Act relative to vehicle recalls       H400       HD1240   \n",
       "3   An Act providing affordable and accessible hig...       H489       HD2794   \n",
       "4   An Act to Improve access, opportunity, and cap...       H538        HD485   \n",
       "5   An Act providing a local option for ranked cho...       H711       HD1183   \n",
       "6   An Act establishing a jail and prison construc...      S1979        SD661   \n",
       "7   An Act relative to collective bargaining right...      S2014       SD1208   \n",
       "8   An Act extending the public records law to the...      S2064        SD390   \n",
       "9   An Act to end discriminatory outcomes in vocat...       S257       SD2312   \n",
       "10  An Act providing affordable and accessible hig...       S301        SD667   \n",
       "11  An Act providing a local option for ranked cho...       S433        SD391   \n",
       "\n",
       "                                         DocumentText  \\\n",
       "0   \\tSECTION 1. Section 1 of Chapter 150E of the ...   \n",
       "1   \\tSECTION 18 of chapter 30A of the General Law...   \n",
       "2   \\tSECTION 1. Chapter 90 of the General Laws, a...   \n",
       "3   \\tSECTION 1. The seventh paragraph of section ...   \n",
       "4   \\tSECTION 1. To create a new capital infrastru...   \n",
       "5   \\tSECTION 1. Section 44A of chapter 43 of the ...   \n",
       "6   \\tSECTION 1. Chapter 7C of the General Laws is...   \n",
       "7   \\tSECTION 1. Section 1 of chapter 150E of the ...   \n",
       "8   \\tSECTION 1. Section 7 of chapter 4 of the Gen...   \n",
       "9   \\tSECTION 1. Chapter 74 of the General Laws is...   \n",
       "10  \\tSECTION 1. The seventh paragraph of section ...   \n",
       "11  \\tSECTION 1. Section 44A of chapter 43 of the ...   \n",
       "\n",
       "                                      List References  \n",
       "0                     [['1', '150E'], ['23', '268A']]  \n",
       "1                                     [['18', '30A']]  \n",
       "2                                                 NaN  \n",
       "3   [['2', '15D'], ['2', '18B'], ['11', '15D'], ['...  \n",
       "4                                     [['10', '70B']]  \n",
       "5                                      [['77', '54']]  \n",
       "6                        [['1', '125'], ['73', '7C']]  \n",
       "7                     [['1', '150E'], ['23', '268A']]  \n",
       "8              [['7', '4'], ['7', '4'], ['10', '66']]  \n",
       "9                                                 NaN  \n",
       "10  [['2', '15D'], ['2', '18B'], ['11', '15D'], ['...  \n",
       "11                                     [['77', '54']]  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_cleaned = df[['Title', 'BillNumber', 'DocketNumber', 'DocumentText', 'List References']]\n",
    "df_cleaned"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "import ast \n",
    "\n",
    "new_df = df_cleaned.copy()\n",
    "\n",
    "new_df['List References'] = df_cleaned['List References'].apply(lambda x: \"None\" if pd.isna(x) else ast.literal_eval(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0                       [[1, 150E], [23, 268A]]\n",
       "1                                   [[18, 30A]]\n",
       "2                                          None\n",
       "3     [[2, 15D], [2, 18B], [11, 15D], [19, 66]]\n",
       "4                                   [[10, 70B]]\n",
       "5                                    [[77, 54]]\n",
       "6                          [[1, 125], [73, 7C]]\n",
       "7                       [[1, 150E], [23, 268A]]\n",
       "8                    [[7, 4], [7, 4], [10, 66]]\n",
       "9                                          None\n",
       "10    [[2, 15D], [2, 18B], [11, 15D], [19, 66]]\n",
       "11                                   [[77, 54]]\n",
       "Name: List References, dtype: object"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_df['List References']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[['2', '15D'], ['2', '18B'], ['11', '15D'], ['19', '66']]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_df['List References'].values[3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "\n",
    "def make_api_call(item):\n",
    "    result = \"\"\"\"\"\"\n",
    "    try:\n",
    "        # unpack section and chapter for example: ['2', '15D']\n",
    "        section, chapter = item\n",
    "        r = requests.get(f'https://malegislature.gov/api/Chapters/{chapter}/Sections/{section}', verify=False)\n",
    "        r = r.json()\n",
    "\n",
    "        # fields to extract\n",
    "        result =  r.get(\"Text\", np.nan)\n",
    "        return result\n",
    "    except:\n",
    "        pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Section 2. There shall be in the executive office of education a department of early education and care, in this chapter called the department, which shall be the state agency responsible for compliance with early education and care services under the Personal Responsibility and Work Opportunity Reconciliation Act of 1996 (Pub. L. 104&ndash;193), or any successor federal statute. The department shall be the state education agency for the purposes of early education and care services under federal law. The department shall seek, apply for and encourage the use of any federal funds for early education and care services, and shall facilitate the coordination of federal, state, and local policies concerning early education and care. The department shall be under the supervision and management of the commissioner of early education and care, in this chapter called the commissioner.  \n",
      "\n",
      "The department shall:&mdash;  \n",
      "\n",
      "(a) be the lead agency of the commonwealth for administering and providing early education and care programs and services to children;  \n",
      "\n",
      "(b) provide early education and care programs and mental health consultation and other support services for children in the commonwealth through grants, contracting for those programs and services, and providing vouchers to participants, and promote the coordination of all such programs and services;  \n",
      "\n",
      "(c) license or approve child care centers, school-aged child care programs, family child care homes and large family child care homes, family foster care which is not supervised and approved by a placement agency, placement agencies, group care facilities, or temporary shelter facilities;  \n",
      "\n",
      "(d) develop and maintain a current consolidated waiting list for all subsidized early education and care programs, and services in the commonwealth;  \n",
      "\n",
      "(e) establish and develop a schedule for revising: (1) a rate structure for voucher and contracted payments to providers of subsidized early education and care programs and services on behalf of low-income and other at-risk children; and (2) a sliding fee scale for participants in those programs. A public hearing under chapter 30A and the approval of the board shall be required before the establishment or revision of the rate structure and sliding fee scale;  \n",
      "\n",
      "(f) manage and implement the Massachusetts universal pre-kindergarten program, established in section 13, that may be phased in over a period of time as determined by the board, and ensure the universal accessibility to the program by using the sliding fee scale developed for early education and care programs;  \n",
      "\n",
      "(g) after a public hearing, adopt criteria including income eligibility requirements, for determining eligibility for an early education and care program or service, including the universal pre-kindergarten program under this chapter and develop a schedule for revising such criteria. Income eligibility requirements shall include a maximum allowable income for working families;  \n",
      "\n",
      "(h) monitor and evaluate on an ongoing basis all early education and care programs and services, including program outcomes in meeting the developmental and educational needs of all children;  \n",
      "\n",
      "(i) analyze and evaluate all budget requests for early education and care programs and services, including requests from secretaries, departments, agencies, or other offices within the commonwealth and make recommendations to the secretary of education, general court, appropriate secretaries, departments, agencies, or other offices regarding coordination and approval of those budget requests;  \n",
      "\n",
      "(j) lease, purchase, hold and dispose of personal and real property it considers necessary to carry out this chapter;  \n",
      "\n",
      "(k) seek to increase the availability of early education and care programs and services and encourage all providers of those programs and services to work together to create an array of options allowing families to select programs that fit with their schedules;  \n",
      "\n",
      "(l) provide information and referral to persons seeking early education and care programs and services;  \n",
      "\n",
      "(m) work in conjunction with the department of transitional assistance to obtain federal reimbursement under the federal Social Security Act for all participants in publicly-funded early education and care programs and services who are eligible;  \n",
      "\n",
      "(n) promote the development of early education and care services for children by seeking and accepting federal grants as well as assisting other agencies of the commonwealth and local agencies to take full advantage of all federal funds available for those services;  \n",
      "\n",
      "(o) provide technical assistance and consultation to providers and potential providers of early education and care services;  \n",
      "\n",
      "(p) facilitate the development of the early education and care workforce, and, when appropriate, provide for training programs and professional development for persons offering early education and care programs and services;  \n",
      "\n",
      "(q) establish and regularly update: (1) a comprehensive database of early childhood educators and providers, hereinafter referred to as the educator database, for the purpose of enhancing the workforce development system; and (2) a comprehensive database of children both waiting for and receiving early education and care services, in this chapter called the student database, that is compatible with relevant databases at the department of elementary and secondary education and the executive office of health and human services; and  \n",
      "\n",
      "(r) collect and disseminate information to assist parents in nurturing their children's development and education. This information shall be made widely available in written form and accessible through the department's website, in English and other commonly spoken languages in the commonwealth.  \n",
      "\n",
      "(s) plan for and address the unique needs of families with infants and toddlers, including providing parent education, early literacy services and meaningful opportunities for families not enrolled in early education and care to support their children's development.  \n",
      "\n",
      "(t) subject to appropriation, provide consultation services and workforce development to meet the behavioral health needs of children in early education and care programs, giving preference to those services designed to prevent expulsions and suspensions.  \n",
      "\n",
      "(u) subject to appropriation and notwithstanding any general or special law to the contrary, assure quality early education and care provided to children through family child care providers by working cooperatively with family child care providers to build upon the existing system and continuously improve the delivery of high quality early education and care services for eligible low income families through providers who have the requisite skills and training.   \n",
      "\n",
      "Section 2. The department shall provide and administer a comprehensive child welfare program for children and families, including the following services:&mdash;  \n",
      "\n",
      "(1) casework or counseling, including services to families, foster families or individuals;  \n",
      "\n",
      "(2) protective services for children;  \n",
      "\n",
      "(3) legal services for families, children or individuals who are clients of the department;  \n",
      "\n",
      "(4) adoption services;  \n",
      "\n",
      "(5) information and referral services;  \n",
      "\n",
      "(6) foster family care for children and specialized foster family care for children with special needs;  \n",
      "\n",
      "(7) residential care for children with special needs who are not suited for foster family care or specialized foster family care;  \n",
      "\n",
      "(8) informal education and group activities;  \n",
      "\n",
      "(9) training in parenthood and home management for parents, foster parents and prospective parents;  \n",
      "\n",
      "(10) family services intended to prevent the need for foster care and services to children in foster care;  \n",
      "\n",
      "(11) temporary residential programs providing counseling and supportive assistance for families in transition and their children who, because of domestic violence, homelessness, or other situations, require temporary shelter and assistance;  \n",
      "\n",
      "(12) camping services;  \n",
      "\n",
      "(13) information and referral services;  \n",
      "\n",
      "(14) services for families and individuals in emergency and transitional housing;  \n",
      "\n",
      "(15) comprehensive youth development services;  \n",
      "\n",
      "(16) access to and coordination of medical, dental and mental health services for children in foster care whose families are receiving services from other state agencies; and  \n",
      "\n",
      "(17) child care placements for children whose families have an open case with the department.   \n",
      "\n",
      "Section 11. The board, after holding a public hearing, shall adopt, and develop a schedule for revising, program quality standards and requirements that any early education and care program or provider shall meet. The department shall develop separate but related standards for children in the following developmental stages: infant and toddler, pre-school, early elementary and older school-age; and for additional developmental stages that the department may determine relevant based on research and best practices.  These standards and requirements shall incorporate essential elements of high-quality early education and care that promote healthy, cognitive, linguistic, social, emotional and physical outcomes, and school readiness based on curriculum frameworks. Standards and requirements shall build upon the licensure regulations promulgated under section 8.  \n",
      "\n",
      "(a) The standards for all developmental stages and any succeeding developmental stages adopted by the department shall be incorporated into a single document and linked by a common philosophy and consistent goals and guiding principles. This document shall also include the policy developed jointly with the department and board of elementary and secondary education required under section 13 to ensure smooth transitions between infant and toddler programs, preschool and kindergarten. The standards shall be regularly updated to reflect applicable research and best practices. The board shall submit standards and requirements, or revisions of them, to the joint committee on education and the house and senate committees on ways and means at least 60 days before adoption. The joint committee on education shall review and comment on the rules and regulations during that time period.  \n",
      "\n",
      "(b) The board shall include, in its adoption and revision of program quality standards, a specific focus on the unique requirements and needs of preschool-aged children including, but not limited to, rigorous guidelines for preschool learning experiences. Every early education and care program or provider shall be required to meet these standards in order to participate in the Massachusetts universal pre-kindergarten program, established in section 13.  \n",
      "\n",
      "(c) The department, with approval of the board, shall develop a consistent set of learning standards for all preschool programs in the commonwealth, to be included in the program quality standards. The standards shall be consistent with the curriculum frameworks developed by the department of elementary and secondary education, shall be research-based and shall be updated regularly to reflect best practices in the field of early education and care. The standards shall guarantee, at a minimum, that every program participating in the Massachusetts universal pre-kindergarten program shall include consultation and intervention services for children at risk for expulsion.  \n",
      "\n",
      "(d) With the approval of the board, the department shall develop and establish a schedule for revising a comprehensive set of developmental benchmarks which may be incorporated into the quality standards, and which may be used by all early education and care programs in measuring children's developmental progress utilizing the healthy, cognitive, linguistic, social, emotional and physical outcomes for developing the quality standards. In developing the benchmarks, the department shall collaborate with pediatricians, child psychologists, and researchers within the field of child development and developmental psychology, in order to ensure that the document reflects best practices in the field and the most recent evidence provided by science relative to early childhood development.   \n",
      "\n",
      "Section 19. (a) When designing or acquiring an electronic record keeping system or database, records access officers shall, consistent with section 17 of chapter 110G, consult with their chief executive officer, chief administrative officer or the Massachusetts office of information technology pursuant to chapter 7D to ensure, to the extent feasible, that the system or database is capable of providing data in a commonly available electronic, machine readable format. Such database designs or acquisitions shall allow for, to the extent feasible, information storage and retrieval methods that permit the segregation and retrieval of public records and redacting of exempt information in order to provide maximum public access. No agency or municipality shall enter into a contract for the storage of electronic records containing public records if the contract prevents or unduly restricts the records access officer from providing the public records in accordance with this chapter.  \n",
      "\n",
      "(b) Every agency shall provide on a searchable website electronic copies, accessible in a commonly available electronic format, of the following types of records, provided that any agency may withhold any record or portion thereof in accordance with state or federal law:  \n",
      "\n",
      "(i) final opinions, decisions, orders, or votes from agency proceedings;  \n",
      "\n",
      "(ii) annual reports;  \n",
      "\n",
      "(iii) notices of regulations proposed under chapter 30A;  \n",
      "\n",
      "(iv) notices of hearings;  \n",
      "\n",
      "(v) winning bids for public contracts;  \n",
      "\n",
      "(vi) awards of federal, state and municipal government grants;  \n",
      "\n",
      "(vii) minutes of open meetings;  \n",
      "\n",
      "(viii) agency budgets; and  \n",
      "\n",
      "(ix) any public record information of significant interest that the agency deems appropriate to post.   \n",
      "\n",
      "\n",
      "14007\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n"
     ]
    }
   ],
   "source": [
    "sample_1 = new_df['List References'].values[3]\n",
    "\n",
    "result = \"\"\"\"\"\"\n",
    "# Storing and printing each pair\n",
    "formatted_data = []\n",
    "for pair in sample_1:\n",
    "    string = make_api_call(pair)\n",
    "    result += string\n",
    "    \n",
    "\n",
    "print(result)\n",
    "print(len(result))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "this is in the format of section, chapter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n",
      "c:\\Users\\16178\\anaconda3\\envs\\maple\\Lib\\site-packages\\urllib3\\connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'malegislature.gov'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
      "  warnings.warn(\n"
     ]
    }
   ],
   "source": [
    "new_df['MGL'] = new_df['List References'].apply(lambda pairs: [make_api_call(item) for item in pairs if item is not None])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Title              An Act providing affordable and accessible hig...\n",
       "BillNumber                                                      H489\n",
       "DocketNumber                                                  HD2794\n",
       "DocumentText       \\tSECTION 1. The seventh paragraph of section ...\n",
       "List References            [[2, 15D], [2, 18B], [11, 15D], [19, 66]]\n",
       "MGL                [Section 2. There shall be in the executive of...\n",
       "Name: 3, dtype: object"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_df.iloc[3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[\"Section 2. There shall be in the executive office of education a department of early education and care, in this chapter called the department, which shall be the state agency responsible for compliance with early education and care services under the Personal Responsibility and Work Opportunity Reconciliation Act of 1996 (Pub. L. 104&ndash;193), or any successor federal statute. The department shall be the state education agency for the purposes of early education and care services under federal law. The department shall seek, apply for and encourage the use of any federal funds for early education and care services, and shall facilitate the coordination of federal, state, and local policies concerning early education and care. The department shall be under the supervision and management of the commissioner of early education and care, in this chapter called the commissioner.  \\r\\n\\r\\nThe department shall:&mdash;  \\r\\n\\r\\n(a) be the lead agency of the commonwealth for administering and providing early education and care programs and services to children;  \\r\\n\\r\\n(b) provide early education and care programs and mental health consultation and other support services for children in the commonwealth through grants, contracting for those programs and services, and providing vouchers to participants, and promote the coordination of all such programs and services;  \\r\\n\\r\\n(c) license or approve child care centers, school-aged child care programs, family child care homes and large family child care homes, family foster care which is not supervised and approved by a placement agency, placement agencies, group care facilities, or temporary shelter facilities;  \\r\\n\\r\\n(d) develop and maintain a current consolidated waiting list for all subsidized early education and care programs, and services in the commonwealth;  \\r\\n\\r\\n(e) establish and develop a schedule for revising: (1) a rate structure for voucher and contracted payments to providers of subsidized early education and care programs and services on behalf of low-income and other at-risk children; and (2) a sliding fee scale for participants in those programs. A public hearing under chapter 30A and the approval of the board shall be required before the establishment or revision of the rate structure and sliding fee scale;  \\r\\n\\r\\n(f) manage and implement the Massachusetts universal pre-kindergarten program, established in section 13, that may be phased in over a period of time as determined by the board, and ensure the universal accessibility to the program by using the sliding fee scale developed for early education and care programs;  \\r\\n\\r\\n(g) after a public hearing, adopt criteria including income eligibility requirements, for determining eligibility for an early education and care program or service, including the universal pre-kindergarten program under this chapter and develop a schedule for revising such criteria. Income eligibility requirements shall include a maximum allowable income for working families;  \\r\\n\\r\\n(h) monitor and evaluate on an ongoing basis all early education and care programs and services, including program outcomes in meeting the developmental and educational needs of all children;  \\r\\n\\r\\n(i) analyze and evaluate all budget requests for early education and care programs and services, including requests from secretaries, departments, agencies, or other offices within the commonwealth and make recommendations to the secretary of education, general court, appropriate secretaries, departments, agencies, or other offices regarding coordination and approval of those budget requests;  \\r\\n\\r\\n(j) lease, purchase, hold and dispose of personal and real property it considers necessary to carry out this chapter;  \\r\\n\\r\\n(k) seek to increase the availability of early education and care programs and services and encourage all providers of those programs and services to work together to create an array of options allowing families to select programs that fit with their schedules;  \\r\\n\\r\\n(l) provide information and referral to persons seeking early education and care programs and services;  \\r\\n\\r\\n(m) work in conjunction with the department of transitional assistance to obtain federal reimbursement under the federal Social Security Act for all participants in publicly-funded early education and care programs and services who are eligible;  \\r\\n\\r\\n(n) promote the development of early education and care services for children by seeking and accepting federal grants as well as assisting other agencies of the commonwealth and local agencies to take full advantage of all federal funds available for those services;  \\r\\n\\r\\n(o) provide technical assistance and consultation to providers and potential providers of early education and care services;  \\r\\n\\r\\n(p) facilitate the development of the early education and care workforce, and, when appropriate, provide for training programs and professional development for persons offering early education and care programs and services;  \\r\\n\\r\\n(q) establish and regularly update: (1) a comprehensive database of early childhood educators and providers, hereinafter referred to as the educator database, for the purpose of enhancing the workforce development system; and (2) a comprehensive database of children both waiting for and receiving early education and care services, in this chapter called the student database, that is compatible with relevant databases at the department of elementary and secondary education and the executive office of health and human services; and  \\r\\n\\r\\n(r) collect and disseminate information to assist parents in nurturing their children's development and education. This information shall be made widely available in written form and accessible through the department's website, in English and other commonly spoken languages in the commonwealth.  \\r\\n\\r\\n(s) plan for and address the unique needs of families with infants and toddlers, including providing parent education, early literacy services and meaningful opportunities for families not enrolled in early education and care to support their children's development.  \\r\\n\\r\\n(t) subject to appropriation, provide consultation services and workforce development to meet the behavioral health needs of children in early education and care programs, giving preference to those services designed to prevent expulsions and suspensions.  \\r\\n\\r\\n(u) subject to appropriation and notwithstanding any general or special law to the contrary, assure quality early education and care provided to children through family child care providers by working cooperatively with family child care providers to build upon the existing system and continuously improve the delivery of high quality early education and care services for eligible low income families through providers who have the requisite skills and training.   \\r\\n\\r\\n\",\n",
       " 'Section 2. The department shall provide and administer a comprehensive child welfare program for children and families, including the following services:&mdash;  \\r\\n\\r\\n(1) casework or counseling, including services to families, foster families or individuals;  \\r\\n\\r\\n(2) protective services for children;  \\r\\n\\r\\n(3) legal services for families, children or individuals who are clients of the department;  \\r\\n\\r\\n(4) adoption services;  \\r\\n\\r\\n(5) information and referral services;  \\r\\n\\r\\n(6) foster family care for children and specialized foster family care for children with special needs;  \\r\\n\\r\\n(7) residential care for children with special needs who are not suited for foster family care or specialized foster family care;  \\r\\n\\r\\n(8) informal education and group activities;  \\r\\n\\r\\n(9) training in parenthood and home management for parents, foster parents and prospective parents;  \\r\\n\\r\\n(10) family services intended to prevent the need for foster care and services to children in foster care;  \\r\\n\\r\\n(11) temporary residential programs providing counseling and supportive assistance for families in transition and their children who, because of domestic violence, homelessness, or other situations, require temporary shelter and assistance;  \\r\\n\\r\\n(12) camping services;  \\r\\n\\r\\n(13) information and referral services;  \\r\\n\\r\\n(14) services for families and individuals in emergency and transitional housing;  \\r\\n\\r\\n(15) comprehensive youth development services;  \\r\\n\\r\\n(16) access to and coordination of medical, dental and mental health services for children in foster care whose families are receiving services from other state agencies; and  \\r\\n\\r\\n(17) child care placements for children whose families have an open case with the department.   \\r\\n\\r\\n',\n",
       " \"Section 11. The board, after holding a public hearing, shall adopt, and develop a schedule for revising, program quality standards and requirements that any early education and care program or provider shall meet. The department shall develop separate but related standards for children in the following developmental stages: infant and toddler, pre-school, early elementary and older school-age; and for additional developmental stages that the department may determine relevant based on research and best practices.  These standards and requirements shall incorporate essential elements of high-quality early education and care that promote healthy, cognitive, linguistic, social, emotional and physical outcomes, and school readiness based on curriculum frameworks. Standards and requirements shall build upon the licensure regulations promulgated under section 8.  \\r\\n\\r\\n(a) The standards for all developmental stages and any succeeding developmental stages adopted by the department shall be incorporated into a single document and linked by a common philosophy and consistent goals and guiding principles. This document shall also include the policy developed jointly with the department and board of elementary and secondary education required under section 13 to ensure smooth transitions between infant and toddler programs, preschool and kindergarten. The standards shall be regularly updated to reflect applicable research and best practices. The board shall submit standards and requirements, or revisions of them, to the joint committee on education and the house and senate committees on ways and means at least 60 days before adoption. The joint committee on education shall review and comment on the rules and regulations during that time period.  \\r\\n\\r\\n(b) The board shall include, in its adoption and revision of program quality standards, a specific focus on the unique requirements and needs of preschool-aged children including, but not limited to, rigorous guidelines for preschool learning experiences. Every early education and care program or provider shall be required to meet these standards in order to participate in the Massachusetts universal pre-kindergarten program, established in section 13.  \\r\\n\\r\\n(c) The department, with approval of the board, shall develop a consistent set of learning standards for all preschool programs in the commonwealth, to be included in the program quality standards. The standards shall be consistent with the curriculum frameworks developed by the department of elementary and secondary education, shall be research-based and shall be updated regularly to reflect best practices in the field of early education and care. The standards shall guarantee, at a minimum, that every program participating in the Massachusetts universal pre-kindergarten program shall include consultation and intervention services for children at risk for expulsion.  \\r\\n\\r\\n(d) With the approval of the board, the department shall develop and establish a schedule for revising a comprehensive set of developmental benchmarks which may be incorporated into the quality standards, and which may be used by all early education and care programs in measuring children's developmental progress utilizing the healthy, cognitive, linguistic, social, emotional and physical outcomes for developing the quality standards. In developing the benchmarks, the department shall collaborate with pediatricians, child psychologists, and researchers within the field of child development and developmental psychology, in order to ensure that the document reflects best practices in the field and the most recent evidence provided by science relative to early childhood development.   \\r\\n\\r\\n\",\n",
       " 'Section 19. (a) When designing or acquiring an electronic record keeping system or database, records access officers shall, consistent with section 17 of chapter 110G, consult with their chief executive officer, chief administrative officer or the Massachusetts office of information technology pursuant to chapter 7D to ensure, to the extent feasible, that the system or database is capable of providing data in a commonly available electronic, machine readable format. Such database designs or acquisitions shall allow for, to the extent feasible, information storage and retrieval methods that permit the segregation and retrieval of public records and redacting of exempt information in order to provide maximum public access. No agency or municipality shall enter into a contract for the storage of electronic records containing public records if the contract prevents or unduly restricts the records access officer from providing the public records in accordance with this chapter.  \\r\\n\\r\\n(b) Every agency shall provide on a searchable website electronic copies, accessible in a commonly available electronic format, of the following types of records, provided that any agency may withhold any record or portion thereof in accordance with state or federal law:  \\r\\n\\r\\n(i) final opinions, decisions, orders, or votes from agency proceedings;  \\r\\n\\r\\n(ii) annual reports;  \\r\\n\\r\\n(iii) notices of regulations proposed under chapter 30A;  \\r\\n\\r\\n(iv) notices of hearings;  \\r\\n\\r\\n(v) winning bids for public contracts;  \\r\\n\\r\\n(vi) awards of federal, state and municipal government grants;  \\r\\n\\r\\n(vii) minutes of open meetings;  \\r\\n\\r\\n(viii) agency budgets; and  \\r\\n\\r\\n(ix) any public record information of significant interest that the agency deems appropriate to post.   \\r\\n\\r\\n']"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_df['MGL'].values[3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [],
   "source": [
    "new_df['combined_MGL'] = new_df['MGL'].apply(lambda lst: ' '.join([str(item) for item in lst if item is not None]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "new_df['length_MGL'] = new_df['combined_MGL'].apply(lambda x: len(x) if x else None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     12170.0\n",
       "1      4047.0\n",
       "2         NaN\n",
       "3     14010.0\n",
       "4      5565.0\n",
       "5       680.0\n",
       "6      2813.0\n",
       "7     12170.0\n",
       "8     78184.0\n",
       "9         NaN\n",
       "10    14010.0\n",
       "11      680.0\n",
       "Name: length_MGL, dtype: float64"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_df['length_MGL']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [],
   "source": [
    "new_df.to_csv(\"12billswith.csv\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "maple",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}