forked from topcompare/tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscrapingtool_mortgage.py
2659 lines (2192 loc) · 141 KB
/
scrapingtool_mortgage.py
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
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from bs4 import BeautifulSoup
import urllib.request
from urllib.request import urlopen
import os
from tabula import read_pdf
import requests
import numpy as np
import pandas as pd
from tabulate import tabulate
import json
import requests, PyPDF2, io
import re
import bs4
import sys
import time
from collections import namedtuple
import datetime
import os
import shutil
import urllib.request
import re
import csv
# # __ # #
# # / \ _ # #
# # / /\ \ _____ ____ ____ ____ | |_ ____ # #
# # | /__\ | ___) _ |/ _ ) _ \| _)/ _ | # #
# # | __ | | ( ( | ( (/ /| | | | |_( ( | | # #
# # |_| |_|_| \_|| |\____)_| |_|\___)_||_| # #
# # (_____| # #
def argenta():
df_arge = read_pdf("https://www.argenta.be/content/dam/argenta/documents/emprunter/credit-logement/Feuille%20de%20tarifs%20Cr%C3%A9dits%20hypoth%C3%A9caires.pdf",
encoding="ISO-8859-1", pages=2, area=[184.04, 340, 561.6, 366.48], stream= True, spreadsheet=True, pandas_options={"header": None})
df_arge.columns=["Rates"]
global arge_c
try:
# ARGE0001
df_arge0001 = df_arge.drop(df_arge.index[5:43])
df_arge0001.insert(0,'Formulas','1/1/1 CAP3')
df_arge0001.insert(1,'Min',[0,11,14,16,19])
df_arge0001.insert(2,'Max',[10,13,15,18,20])
df_arge0001.insert(0, 'Provider', 'Argenta')
df_arge0001.insert(1, 'Category', 'Home Loan')
df_arge0001.insert(2, 'Product_ID', 'ARGE0001')
df_arge0001["Rates"] = df_arge0001["Rates"].str.replace(",", ".").str.strip()
df_arge0001["Rates"] = df_arge0001["Rates"].str.replace("%", "").str.strip()
df_arge0001 = df_arge0001[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']]
# ARGE0002
df_arge0002 = df_arge.drop(df_arge.index[0:6]).drop(df_arge.index[11:43])
df_arge0002.insert(0,'Formulas','3/3/3 CAP3')
df_arge0002.insert(1,'Min',[3,11,14,16,19])
df_arge0002.insert(2,'Max',[10,13,15,18,20])
df_arge0002.insert(0, 'Provider', 'Argenta')
df_arge0002.insert(1, 'Category', 'Home Loan')
df_arge0002.insert(2, 'Product_ID', 'ARGE0002')
df_arge0002["Rates"] = df_arge0002["Rates"].str.replace(",", ".").str.strip()
df_arge0002["Rates"] = df_arge0002["Rates"].str.replace("%", "").str.strip()
df_arge0002 = df_arge0002[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']]
# ARGE0003
df_arge0003 = df_arge.drop(df_arge.index[0:12]).drop(df_arge.index[17:43])
df_arge0003.insert(0,'Formulas','5/3/3 CAP3')
df_arge0003.insert(1,'Min',[5,11,14,16,19])
df_arge0003.insert(2,'Max',[10,13,15,18,20])
df_arge0003.insert(0, 'Provider', 'Argenta')
df_arge0003.insert(1, 'Category', 'Home Loan')
df_arge0003.insert(2, 'Product_ID', 'ARGE0003')
df_arge0003["Rates"] = df_arge0003["Rates"].str.replace(",", ".").str.strip()
df_arge0003["Rates"] = df_arge0003["Rates"].str.replace("%", "").str.strip()
df_arge0003 = df_arge0003[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']]
# ARGE0004
df_arge0004 = df_arge.drop(df_arge.index[0:18]).drop(df_arge.index[23:43])
df_arge0004.insert(0,'Formulas','7/3/3 CAP3')
df_arge0004.insert(1,'Min',[7,11,14,16,19])
df_arge0004.insert(2,'Max',[10,13,15,18,20])
df_arge0004.insert(0, 'Provider', 'Argenta')
df_arge0004.insert(1, 'Category', 'Home Loan')
df_arge0004.insert(2, 'Product_ID', 'ARGE0004')
df_arge0004["Rates"] = df_arge0004["Rates"].str.replace(",", ".").str.strip()
df_arge0004["Rates"] = df_arge0004["Rates"].str.replace("%", "").str.strip()
df_arge0004 = df_arge0004[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']]
# ARGE0005
df_arge0005 = df_arge.drop(df_arge.index[0:24]).drop(df_arge.index[28:43])
df_arge0005.insert(0,'Formulas','10/5/5 CAP3')
df_arge0005.insert(1,'Min',[10,14,16,19])
df_arge0005.insert(2,'Max',[13,15,18,20])
df_arge0005.insert(0, 'Provider', 'Argenta')
df_arge0005.insert(1, 'Category', 'Home Loan')
df_arge0005.insert(2, 'Product_ID', 'ARGE0005')
df_arge0005["Rates"] = df_arge0005["Rates"].str.replace(",", ".").str.strip()
df_arge0005["Rates"] = df_arge0005["Rates"].str.replace("%", "").str.strip()
df_arge0005 = df_arge0005[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']]
# ARGE0006
df_arge0006 = df_arge.drop(df_arge.index[0:29]).drop(df_arge.index[31:43])
df_arge0006.insert(0,'Formulas','15/5/5 CAP5')
df_arge0006.insert(1,'Min',[15,19])
df_arge0006.insert(2,'Max',[18,20])
df_arge0006.insert(0, 'Provider', 'Argenta')
df_arge0006.insert(1, 'Category', 'Home Loan')
df_arge0006.insert(2, 'Product_ID', 'ARGE0006')
df_arge0006["Rates"] = df_arge0006["Rates"].str.replace(",", ".").str.strip()
df_arge0006["Rates"] = df_arge0006["Rates"].str.replace("%", "").str.strip()
df_arge0006 = df_arge0006[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']]
# ARGE0007
df_arge0007 = df_arge.drop(df_arge.index[0:32]).drop(df_arge.index[34:43])
df_arge0007.insert(0,'Formulas','15/5/5 CAP5')
df_arge0007.insert(1,'Min',[20,23])
df_arge0007.insert(2,'Max',[22,25])
df_arge0007.insert(0, 'Provider', 'Argenta')
df_arge0007.insert(1, 'Category', 'Home Loan')
df_arge0007.insert(2, 'Product_ID', 'ARGE0007')
df_arge0007["Rates"] = df_arge0007["Rates"].str.replace(",", ".").str.strip()
df_arge0007["Rates"] = df_arge0007["Rates"].str.replace("%", "").str.strip()
df_arge0007 = df_arge0007[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']]
# AGE0008
df_arge0008 = df_arge.drop(df_arge.index[0:35])
df_arge0008.insert(0,'Formulas','Fixed rate')
df_arge0008.insert(1,'Min',[0,11,14,16,19,21,23,26])
df_arge0008.insert(2,'Max',[10,13,15,18,20,22,25,30])
df_arge0008.insert(0, 'Provider', 'Argenta')
df_arge0008.insert(1, 'Category', 'Home Loan')
df_arge0008.insert(2, 'Product_ID', 'ARGE0008')
df_arge0008["Rates"] = df_arge0008["Rates"].str.replace(",", ".").str.strip()
df_arge0008["Rates"] = df_arge0008["Rates"].str.replace("%", "").str.strip()
df_arge0008 = df_arge0008[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']]
# Concatenate
global arge_c
arge_c = pd.concat([
pd.concat([df_arge0001], axis=1),
pd.concat([df_arge0002], axis=1),
pd.concat([df_arge0003], axis=1),
pd.concat([df_arge0004], axis=1),
pd.concat([df_arge0005], axis=1),
pd.concat([df_arge0006], axis=1),
pd.concat([df_arge0007], axis=1),
pd.concat([df_arge0008], axis=1)])
print(tabulate(arge_c, headers='keys', tablefmt='psql', showindex="never"))
except:
pass
def argenta_save():
argenta()
path = os.path.abspath("History/") # saving file to the folder history
file_name = str(datetime.datetime.now().strftime("%Y-%m-%d %H.%M")) + '.csv'
arge_c.to_csv(os.path.join(path, file_name), index=False)
# # ______ _ _ ______ _ # #
# # (____ \ | | | | (____ \ | | # #
# # ____) ) ____ ____ ____ _ _ ____ | | | |___ ____ ____) ) ____ ____ _ | | ____ # #
# # | __ ( / _ | _ \ / _ | | | |/ _ ) \ \/ / _ | _ \ | __ ( / ___) _ ) || |/ _ |# #
# # | |__) | ( | | | | | | | | |_| ( (/ / \ ( ( | | | | | | |__) ) | ( (/ ( (_| ( ( | |# #
# # |______/ \_||_|_| |_|\_|| |\____|\____) \/ \_||_|_| |_| |______/|_| \____)____|\_||_|# #
# # |_| # #
def bvbr():
try:
# BVBR0001
df_bvbr1 = read_pdf('https://www.banquevanbreda.be/media/2480/tariefregeling-jvb-fr-307.pdf', encoding='ISO-8859-1',
pages=1, area=[156.83, 41.09, 229.28, 254.47], pandas_options={'header': None})
df_bvbr0001 = df_bvbr1.drop(df_bvbr1.index[0])
df_bvbr0001 = df_bvbr0001.drop(df_bvbr0001.columns[2:5], axis=1)
df_bvbr0001.columns = ["Formulas", "Rates"]
df_bvbr0001["Formulas"] = df_bvbr0001["Formulas"].str.replace("é", "e").str.strip()
df_bvbr0001["Rates"] = df_bvbr0001["Rates"].str.replace(",", ".").str.strip()
df_bvbr0001["Rates"] = df_bvbr0001["Rates"].str.replace("%", "").str.strip()
Min_bvbr0001 = pd.DataFrame({'Min': ['', '0', '2', '4', '6', '11', '16']})
Max_bvbr0001 = pd.DataFrame({'Max': ['', '1', '3', '5', '10', '15', '20']})
duration_bvbr0001 = Min_bvbr0001.join(Max_bvbr0001)
df_bvbr0001.insert(0, 'Provider', 'Bank Van Breda')
df_bvbr0001.insert(0, 'Category', 'Home Loan')
df_bvbr0001.insert(1, 'Product_ID', 'BVBR0001')
df_bvbr0001 = df_bvbr0001.join(duration_bvbr0001) # join newly made df with existed df
df_bvbr0001 = df_bvbr0001[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BVBR0002
df_bvbr2 = read_pdf('https://www.banquevanbreda.be/media/2480/tariefregeling-jvb-fr-307.pdf', encoding='ISO-8859-1',
pages=1, area=[234.04, 37.96, 286.35, 395.91], pandas_options={'header': None})
df_bvbr0002 = df_bvbr2.drop(df_bvbr2.index[0]).drop(df_bvbr2.index[2:19])
df_bvbr0002 = df_bvbr0002.drop(df_bvbr0002.columns[3:6], axis=1)
df_bvbr0002.columns = ["__", "_", "Rates"]
df_bvbr0002["Formulas"] = df_bvbr0002["__"].map(str) + df_bvbr0002["_"].map(str) # to join Name and CAP column
df_bvbr0002.drop('__', axis=1, inplace=True) # To delete the column by name without having to reassign df
df_bvbr0002.drop('_', axis=1, inplace=True)
# ##Naming purpose
df_bvbr0002["Formulas"] = df_bvbr0002["Formulas"].str.replace("é", "e").str.strip()
df_bvbr0002["Rates"] = df_bvbr0002["Rates"].str.replace(",", ".").str.strip()
df_bvbr0002["Rates"] = df_bvbr0002["Rates"].str.replace("%", "").str.strip()
##Assigning duration: this case doesn't have any duration indicated
Min_bvbr0002 = pd.DataFrame({'Min': [''] * 1 + ['']})
Max_bvbr0002 = pd.DataFrame({'Max': [''] * 1 + ['']})
duration_bvbr0002 = Min_bvbr0002.join(Max_bvbr0002)
df_bvbr0002.insert(0, 'Provider', 'Bank Van Breda')
df_bvbr0002.insert(0, 'Category', 'Home Loan')
df_bvbr0002.insert(1, 'Product_ID', 'BVBR0002')
df_bvbr0002 = df_bvbr0002.join(duration_bvbr0002) # join newly made df with existed df
df_bvbr0002 = df_bvbr0002[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BVBR0003
df_bvbr0003 = df_bvbr2.drop(df_bvbr2.index[0:4]).drop(df_bvbr2.index[5:19])
df_bvbr0003 = df_bvbr0003.drop(df_bvbr0003.columns[3:6], axis=1)
df_bvbr0003.columns = ["__", "_", "Rates"]
df_bvbr0003["Formulas"] = df_bvbr0003["__"].map(str) + df_bvbr0003["_"].map(str) # to join Name and CAP column
df_bvbr0003.drop('__', axis=1, inplace=True) # To delete the column by name without having to reassign df
df_bvbr0003.drop('_', axis=1, inplace=True)
# ##Naming purpose
df_bvbr0003["Formulas"] = df_bvbr0003["Formulas"].str.replace("é", "e").str.strip()
df_bvbr0003["Rates"] = df_bvbr0003["Rates"].str.replace(",", ".").str.strip()
df_bvbr0003["Rates"] = df_bvbr0003["Rates"].str.replace("%", "").str.strip()
##Assigning duration: this case doesn't have any duration indicated
Min_bvbr0003 = pd.DataFrame({'Min': [''] * 4 + ['']})
Max_bvbr0003 = pd.DataFrame({'Max': [''] * 4 + ['']})
duration_bvbr0003 = Min_bvbr0003.join(Max_bvbr0003)
df_bvbr0003.insert(0, 'Provider', 'Bank Van Breda')
df_bvbr0003.insert(0, 'Category', 'Home Loan')
df_bvbr0003.insert(1, 'Product_ID', 'BVBR0003')
df_bvbr0003 = df_bvbr0003.join(duration_bvbr0003) # join newly made df with existed df
df_bvbr0003 = df_bvbr0003[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BVBR0004
df_bvbr0004 = df_bvbr2.drop(df_bvbr2.index[0:7]).drop(df_bvbr2.index[8:19])
df_bvbr0004 = df_bvbr0004.drop(df_bvbr0004.columns[3:6], axis=1)
df_bvbr0004.columns = ["__", "_", "Rates"]
df_bvbr0004["Formulas"] = df_bvbr0004["__"].map(str) + df_bvbr0004["_"].map(str) # to join Name and CAP column
df_bvbr0004.drop('__', axis=1, inplace=True) # To delete the column by name without having to reassign df
df_bvbr0004.drop('_', axis=1, inplace=True)
# ##Naming purpose
df_bvbr0004["Formulas"] = df_bvbr0004["Formulas"].str.replace("é", "e").str.strip()
df_bvbr0004["Rates"] = df_bvbr0004["Rates"].str.replace(",", ".").str.strip()
df_bvbr0004["Rates"] = df_bvbr0004["Rates"].str.replace("%", "").str.strip()
##Assigning duration: this case doesn't have any duration indicated
Min_bvbr0004 = pd.DataFrame({'Min': [''] * 7 + ['']})
Max_bvbr0004 = pd.DataFrame({'Max': [''] * 7 + ['']})
duration_bvbr0004 = Min_bvbr0004.join(Max_bvbr0004)
df_bvbr0004.insert(0, 'Provider', 'Bank Van Breda')
df_bvbr0004.insert(0, 'Category', 'Home Loan')
df_bvbr0004.insert(1, 'Product_ID', 'BVBR0004')
df_bvbr0004 = df_bvbr0004.join(duration_bvbr0004) # join newly made df with existed df
df_bvbr0004 = df_bvbr0004[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BVBR0005
df_bvbr0005 = df_bvbr2.drop(df_bvbr2.index[0:10]).drop(df_bvbr2.index[11:19])
df_bvbr0005 = df_bvbr0005.drop(df_bvbr0005.columns[3:6], axis=1)
df_bvbr0005.columns = ["__", "_", "Rates"]
df_bvbr0005["Formulas"] = df_bvbr0005["__"].map(str) + df_bvbr0005["_"].map(str) # to join Name and CAP column
df_bvbr0005.drop('__', axis=1, inplace=True) # To delete the column by name without having to reassign df
df_bvbr0005.drop('_', axis=1, inplace=True)
# ##Naming purpose
df_bvbr0005["Formulas"] = df_bvbr0005["Formulas"].str.replace("é", "e").str.strip()
df_bvbr0005["Rates"] = df_bvbr0005["Rates"].str.replace(",", ".").str.strip()
df_bvbr0005["Rates"] = df_bvbr0005["Rates"].str.replace("%", "").str.strip()
##Assigning duration: this case doesn't have any duration indicated
Min_bvbr0005 = pd.DataFrame({'Min': [''] * 10 + ['']})
Max_bvbr0005 = pd.DataFrame({'Max': [''] * 10 + ['']})
duration_bvbr0005 = Min_bvbr0005.join(Max_bvbr0005)
df_bvbr0005.insert(0, 'Provider', 'Bank Van Breda')
df_bvbr0005.insert(0, 'Category', 'Home Loan')
df_bvbr0005.insert(1, 'Product_ID', 'BVBR0005')
df_bvbr0005 = df_bvbr0005.join(duration_bvbr0005) # join newly made df with existed df
df_bvbr0005 = df_bvbr0005[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BVBR0006
df_bvbr0006 = df_bvbr2.drop(df_bvbr2.index[0:13]).drop(df_bvbr2.index[14:19])
df_bvbr0006 = df_bvbr0006.drop(df_bvbr0006.columns[3:6], axis=1)
df_bvbr0006.columns = ["__", "_", "Rates"]
df_bvbr0006["Formulas"] = df_bvbr0006["__"].map(str) + df_bvbr0006["_"].map(str) # to join Name and CAP column
df_bvbr0006.drop('__', axis=1, inplace=True) # To delete the column by name without having to reassign df
df_bvbr0006.drop('_', axis=1, inplace=True)
# ##Naming purpose
df_bvbr0006["Formulas"] = df_bvbr0006["Formulas"].str.replace("é", "e").str.strip()
df_bvbr0006["Rates"] = df_bvbr0006["Rates"].str.replace(",", ".").str.strip()
df_bvbr0006["Rates"] = df_bvbr0006["Rates"].str.replace("%", "").str.strip()
# ##Assigning duration: this case doesn't have any duration indicated
Min_bvbr0006 = pd.DataFrame({'Min': [''] * 13 + ['']})
Max_bvbr0006 = pd.DataFrame({'Max': [''] * 13 + ['']})
duration_bvbr0006 = Min_bvbr0006.join(Max_bvbr0006)
df_bvbr0006.insert(0, 'Provider', 'Bank Van Breda')
df_bvbr0006.insert(0, 'Category', 'Home Loan')
df_bvbr0006.insert(1, 'Product_ID', 'BVBR0006')
df_bvbr0006 = df_bvbr0006.join(duration_bvbr0006) # join newly made df with existed df
df_bvbr0006 = df_bvbr0006[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BVBR0007
df_bvbr0007 = df_bvbr2.drop(df_bvbr2.index[0:16]).drop(df_bvbr2.index[17:19])
df_bvbr0007 = df_bvbr0007.drop(df_bvbr0007.columns[3:6], axis=1)
df_bvbr0007.columns = ["__", "_", "Rates"]
df_bvbr0007["Formulas"] = df_bvbr0007["__"].map(str) + df_bvbr0007["_"].map(str) # to join Name and CAP column
df_bvbr0007.drop('__', axis=1, inplace=True) # To delete the column by name without having to reassign df
df_bvbr0007.drop('_', axis=1, inplace=True)
# ##Naming purpose
df_bvbr0007["Formulas"] = df_bvbr0007["Formulas"].str.replace("é", "e").str.strip()
df_bvbr0007["Rates"] = df_bvbr0007["Rates"].str.replace(",", ".").str.strip()
df_bvbr0007["Rates"] = df_bvbr0007["Rates"].str.replace("%", "").str.strip()
##Assigning duration: this case doesn't have any duration indicated
Min_bvbr0007 = pd.DataFrame({'Min': [''] * 16 + ['']})
Max_bvbr0007 = pd.DataFrame({'Max': [''] * 16 + ['']})
duration_bvbr0007 = Min_bvbr0007.join(Max_bvbr0007)
df_bvbr0007.insert(0, 'Provider', 'Bank Van Breda')
df_bvbr0007.insert(0, 'Category', 'Home Loan')
df_bvbr0007.insert(1, 'Product_ID', 'BVBR0007')
df_bvbr0007 = df_bvbr0007.join(duration_bvbr0007) # join newly made df with existed df
df_bvbr0007 = df_bvbr0007[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# Concatenate
global bvbr_c
bvbr_c = pd.concat([
pd.concat([df_bvbr0001], axis=1),
pd.concat([df_bvbr0002], axis=1),
pd.concat([df_bvbr0003], axis=1),
pd.concat([df_bvbr0004], axis=1),
pd.concat([df_bvbr0005], axis=1),
pd.concat([df_bvbr0006], axis=1),
pd.concat([df_bvbr0007], axis=1)])
print(tabulate(bvbr_c, headers='keys', tablefmt='psql', showindex="never"))
except:
pass
def bvbr_save():
bvbr()
path = os.path.abspath("History/") # saving file to the folder history
file_name = str(datetime.datetime.now().strftime("%Y-%m-%d %H.%M")) + '.csv'
# Line below is used to concat the whole dfs and save it into a csv file
bvbr_c.to_csv(os.path.join(path, file_name), index=False)
# # ______ ______ # #
# # (____ \(_____ \ _ # #
# # ____) )_____) )__ ___| |_ # #
# # | __ (| ____/ _ \ /___) _) # #
# # | |__) ) | | |_| |___ | |__ # #
# # |______/|_| \___/(___/ \___)# #
def bpost():
try:
url_bpos0001 = 'https://www.bpostbanque.be/bpb/emprunter/credit-hypothecaire'
page_bpos0001 = requests.get(url_bpos0001).content
soup_bpos0001 = BeautifulSoup(page_bpos0001, "html.parser")
pattern_bpos0001 = re.compile(r"xml version=.")
script_bpos0001 = soup_bpos0001.find("script", text=pattern_bpos0001)
print(script_bpos0001)
HL_bpost = str(script_bpos0001)[174585:176860]
print(HL_bpost)
# BPOST0001
for _ in script_bpos0001:
formules_BPOS0001 = (re.findall(r'property label="(.*?)" name="tauxFixe"', HL_bpost)) * 6
min_BPOS0001 = ['0', '11', '16', '19', '21', '26']
max_BPOS0001 = ['10', '15', '18', '20', '25', '30']
taux_BPOS0001_ = re.findall(r'<value type="string">.(.*?).<.value><.property><property label="Titre Rates annuel fixe"', HL_bpost)
taux_BPOS0001 = [element for item in taux_BPOS0001_ for element in item.split(',')]
BPOS0001_array = np.column_stack((min_BPOS0001, max_BPOS0001, taux_BPOS0001))
BPOS0001_tup = tuple(map(tuple, BPOS0001_array))
df_BPOS0001 = pd.DataFrame(list(BPOS0001_tup))
df_BPOS0001.columns = ["Min", "Max", "Rates"]
df_BPOS0001.insert(0, 'Provider', 'BPost')
df_BPOS0001.insert(1, 'Product_ID', 'BPOS0001')
df_BPOS0001.insert(2, 'Category', 'Home Loan')
df_BPOS0001.insert(3, 'Formulas', formules_BPOS0001)
# BPOS0002
for _ in script_bpos0001:
formules_BPOS0002 = (re.findall(r'nouvelle formule<.value><.property><property label="(.*?)" name="tauxVariable"', HL_bpost)) * 6
min_BPOS0002 = ['0', '11', '16', '19', '21', '26']
max_BPOS0002 = ['10', '15', '18', '20', '25', '30']
taux_BPOS0002_ = re.findall(r'Rates annuel variable 5.5.5" name="tauxVariable" readonly="true" itemName="widget-simulator-morgage-custom-8840771" viewHint="text-input,admin,designModeOnly"><value type="string">(.*?)<.value>', HL_bpost) * 6
taux_BPOS0002 = [element for item in taux_BPOS0002_ for element in item.split(',')]
BPOS0002_array = np.column_stack((min_BPOS0002, max_BPOS0002, taux_BPOS0002))
BPOS0002_tup = tuple(map(tuple, BPOS0002_array))
df_BPOS0002 = pd.DataFrame(list(BPOS0002_tup))
df_BPOS0002.columns = ["Min", "Max", "Rates"]
df_BPOS0002.insert(0, 'Provider', 'BPost')
df_BPOS0002.insert(1, 'Product_ID', 'BPOS0002')
df_BPOS0002.insert(2, 'Category', 'Home Loan')
df_BPOS0002.insert(3, 'Formulas', formules_BPOS0002)
# BPOS0003
for _ in script_bpos0001:
formules_BPOS0003 = (re.findall(r'tauxVariable.*<.value><.property><property label="(.*?)" name="tauxVariable1" readonly="true"', HL_bpost)) * 6
min_BPOS0003 = ['0', '11', '16', '19', '21', '26']
max_BPOS0003 = ['10', '15', '18', '20', '25', '30']
taux_BPOS0003_ = re.findall(r'Rates annuel variable 10.5.5 1" name="tauxVariable1" readonly="true" itemName="widget-simulator-morgage-custom-8840771" viewHint="text-input,admin,designModeOnly"><value type="string">(.*?)<.value', HL_bpost) * 6
taux_BPOS0003 = [element for item in taux_BPOS0003_ for element in item.split(',')]
BPOS0003_array = np.column_stack((min_BPOS0003, max_BPOS0003, taux_BPOS0003))
BPOS0003_tup = tuple(map(tuple, BPOS0003_array))
df_BPOS0003 = pd.DataFrame(list(BPOS0003_tup))
df_BPOS0003.columns = ["Min", "Max", "Rates"]
df_BPOS0003.insert(0, 'Provider', 'BPost')
df_BPOS0003.insert(1, 'Product_ID', 'BPOS0003')
df_BPOS0003.insert(2, 'Category', 'Home Loan')
df_BPOS0003.insert(3, 'Formulas', formules_BPOS0003)
# BPOS0004
for _ in script_bpos0001:
formules_BPOS0004 = (re.findall(r'tauxVariable.*<.value><.property><property label="(.*?)" name="tauxVariable2" readonly="true"', HL_bpost)) * 6
min_BPOS0004 = ['0', '11', '16', '19', '21', '26']
max_BPOS0004 = ['10', '15', '18', '20', '25', '30']
taux_BPOS0004_ = re.findall(r'10.5.5 2" name="tauxVariable2" readonly="true" itemName="widget-simulator-morgage-custom-8840771" viewHint="text-input,admin,designModeOnly"><value type="string">(.*?)<.value', HL_bpost) * 6
taux_BPOS0004 = [element for item in taux_BPOS0004_ for element in item.split(',')]
BPOS0004_array = np.column_stack((min_BPOS0004, max_BPOS0004, taux_BPOS0004))
BPOS0004_tup = tuple(map(tuple, BPOS0004_array))
df_BPOS0004 = pd.DataFrame(list(BPOS0004_tup))
df_BPOS0004.columns = ["Min", "Max", "Rates"]
df_BPOS0004.insert(0, 'Provider', 'BPost')
df_BPOS0004.insert(1, 'Product_ID', 'BPOS0004')
df_BPOS0004.insert(2, 'Category', 'Home Loan')
df_BPOS0004.insert(3, 'Formulas', formules_BPOS0004)
# Concatenate
global bpos_c
bpos_c = pd.concat([
pd.concat([df_BPOS0001], axis=1),
pd.concat([df_BPOS0002], axis=1),
pd.concat([df_BPOS0003], axis=1),
pd.concat([df_BPOS0004], axis=1)])
print(tabulate(bpos_c, headers='keys', tablefmt='psql', showindex="never"))
except:
pass
def bpost_save():
bpost()
path = os.path.abspath("History/") # saving file to the folder history
file_name = str(datetime.datetime.now().strftime("%Y-%m-%d %H.%M")) + '.csv'
bpos_c.to_csv(os.path.join(path, file_name), index=False)
# # ______ _ _____ # #
# # (____ \ | |/ __(_) # #
# # ____) ) ____| | |__ _ _ _ ___ # #
# # | __ ( / _ ) | __) | | | |/___) # #
# # | |__) | (/ /| | | | | |_| |___ | # #
# # |______/ \____)_|_| |_|\____(___/ # #
# # # #
def belfius():
try:
# BELF0001
df_belf0001 = read_pdf('https://www.belfius.be/imagingservlet/GetDocument?src=mifid&id=TARIFLOANFIDELITY_FR', encoding='ISO-8859-1',
stream=True, area=[269.875, 12.75, 380.5, 961], pages=1, guess=False, pandas_options={'header': None})
df_belf0001 = df_belf0001.drop(df_belf0001.index[[0, 1]]) # drop the first 2 lines
df_belf0001.drop(df_belf0001.columns[3], axis=1, inplace=True) # drop the column Rates Mensuel
df_belf0001.columns = ["Formulas", "Min", "Max", "Rates"]
df_belf0001["Min"] = df_belf0001["Min"].str.replace(" mois", "").str.strip() # delete "Mois" in Min and Max
df_belf0001["Max"] = df_belf0001["Max"].str.replace(" mois", "").str.strip()
df_belf0001["Rates"] = df_belf0001["Rates"].str.replace(",", ".").str.strip()
df_belf0001["Rates"] = df_belf0001["Rates"].str.replace(" %", "").str.strip() # delete % so we can calculate below
df_belf0001["Rates"] = ((df_belf0001["Rates"].astype(float) / 100) + (0.5 / 100)) * 100 # multiply values by specific rate of 0.5%
df_belf0001.insert(0, 'Provider', 'Belfius')
df_belf0001.insert(1, 'Product_ID', 'BELF0001')
df_belf0001.insert(2, 'Category', 'Home Loan')
df_belf0001 = df_belf0001[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BELF0002
df_belf0002 = read_pdf('https://www.belfius.be/imagingservlet/GetDocument?src=mifid&id=TARIFLOANFIDELITY_FR', encoding='ISO-8859-1',
stream=True, spreadsheet=True, area=[555.46, 113.18, 666.39, 549.68], pages=1, guess=False, pandas_options={'header': None})
df_belf0002 = df_belf0002.drop(df_belf0002.index[[0, 1, 2]]) # drop the first 2 lines --> USE THIS IF YOU WANNA DROP ONE BY ONE
df_belf0002.drop(df_belf0002.columns[1:3], axis=1, inplace=True) # drop the CAP columns
df_belf0002.drop(df_belf0002.columns[3], axis=1, inplace=True) # drop the column Rates Mensuel
df_belf0002.columns = ["Formulas", "Min", "Max", "Rates"]
df_belf0002["Min"] = df_belf0002["Min"].str.replace(" mois", "").str.strip() # delete "Mois" in Min and Max
df_belf0002["Max"] = df_belf0002["Max"].str.replace(" mois", "").str.strip()
df_belf0002["Rates"] = df_belf0002["Rates"].str.replace(",", ".").str.strip()
df_belf0002["Rates"] = df_belf0002["Rates"].str.replace(" %", "").str.strip() # delete % so we can calculate below
df_belf0002["Rates"] = ((df_belf0002["Rates"].astype(float) / 100) + (0.5 / 100)) * 100 # multiply values by specific rate of 0.5%
df_belf0002.insert(0, 'Provider', 'Belfius')
df_belf0002.insert(1, 'Product_ID', 'BELF0002')
df_belf0002.insert(2, 'Category', 'Home Loan')
df_belf0002 = df_belf0002[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BELF0003
df_belf0003 = read_pdf('https://www.belfius.be/imagingservlet/GetDocument?src=mifid&id=TARIFLOANFIDELITY_FR', encoding='ISO-8859-1',
stream=True, spreadsheet=True, area=[555.09, 113.52, 740.38, 656.1], pages=1, guess=False, pandas_options={'header': None})
df_belf0003 = df_belf0003.drop(df_belf0003.index[0:6]) # drop top lines --> USE THIS IF YOU WANNA DROP RANGE
df_belf0003.drop(df_belf0003.columns[1:3], axis=1, inplace=True) # drop the CAP columns
df_belf0003.drop(df_belf0003.columns[3], axis=1, inplace=True) # drop the column Rates Mensuel
df_belf0003.columns = ["Formulas", "Min", "Max", "Rates"]
df_belf0003["Min"] = df_belf0003["Min"].str.replace(" mois", "").str.strip() # delete "Mois" in Min and Max
df_belf0003["Max"] = df_belf0003["Max"].str.replace(" mois", "").str.strip()
df_belf0003["Rates"] = df_belf0003["Rates"].str.replace(",", ".").str.strip()
df_belf0003["Rates"] = df_belf0003["Rates"].str.replace(" %", "").str.strip() # delete % so we can calculate below
df_belf0003["Rates"] = ((df_belf0003["Rates"].astype(float) / 100) + (0.5 / 100)) * 100 # multiply values by specific rate of 0.5%
df_belf0003.insert(0, 'Provider', 'Belfius')
df_belf0003.insert(1, 'Product_ID', 'BELF0003')
df_belf0003.insert(2, 'Category', 'Home Loan')
df_belf0003 = df_belf0003[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BELF0004
df_belf0004 = read_pdf('https://www.belfius.be/imagingservlet/GetDocument?src=mifid&id=TARIFLOANFIDELITY_FR', encoding='ISO-8859-1',
stream=True, spreadsheet=True, area=[555.09, 113.52, 786.41, 724.65], pages=1, guess=False, pandas_options={'header': None})
df_belf0004 = df_belf0004.drop(df_belf0004.index[0:10]) # drop top lines --> USE THIS IF YOU WANNA DROP RANGE
df_belf0004.drop(df_belf0004.columns[1:3], axis=1, inplace=True) # drop the CAP columns
df_belf0004.drop(df_belf0004.columns[3], axis=1, inplace=True) # drop the column Rates Mensuel
df_belf0004.columns = ["Formulas", "Min", "Max", "Rates"]
df_belf0004["Min"] = df_belf0004["Min"].str.replace(" mois", "").str.strip() # delete "Mois" in Min and Max
df_belf0004["Max"] = df_belf0004["Max"].str.replace(" mois", "").str.strip()
df_belf0004["Rates"] = df_belf0004["Rates"].str.replace(",", ".").str.strip()
df_belf0004["Rates"] = df_belf0004["Rates"].str.replace(" %", "").str.strip() # delete % so we can calculate below
df_belf0004["Rates"] = ((df_belf0004["Rates"].astype(float) / 100) + (0.5 / 100)) * 100 # multiply values by specific rate of 0.5%
df_belf0004.insert(0, 'Provider', 'Belfius')
df_belf0004.insert(1, 'Product_ID', 'BELF0004')
df_belf0004.insert(2, 'Category', 'Home Loan')
df_belf0004 = df_belf0004[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BELF0005
df_belf0005_1 = read_pdf('https://www.belfius.be/imagingservlet/GetDocument?src=mifid&id=TARIFLOANFIDELITY_FR', encoding='ISO-8859-1',
stream=True, spreadsheet=True, area=[555.09, 113.52, 886.41, 724.65], pages=1, guess=False, pandas_options={'header': None})
df_belf0005_1 = df_belf0005_1.drop(df_belf0005_1.index[0:13]) # drop top lines --> USE THIS IF YOU WANNA DROP RANGE
df_belf0005_1.drop(df_belf0005_1.columns[1:3], axis=1, inplace=True) # drop the CAP columns
df_belf0005_1.columns = ["Formulas", "Min", "Max", "_TauxMens_", "Rates"]
df_belf0005_1.drop(df_belf0005_1.columns[3], axis=1, inplace=True) # drop the column Rates Mensuel
df_belf0005_1["Min"] = df_belf0005_1["Min"].str.replace(" mois", "").str.strip() # delete "Mois" in Min and Max
df_belf0005_1["Max"] = df_belf0005_1["Max"].str.replace(" mois", "").str.strip()
df_belf0005_1["Rates"] = df_belf0005_1["Rates"].str.replace(",", ".").str.strip()
df_belf0005_1["Rates"] = df_belf0005_1["Rates"].str.replace(" %", "").str.strip() # delete % so we can calculate below
df_belf0005_1["Rates"] = ((df_belf0005_1["Rates"].astype(float) / 100) + (0.5 / 100)) * 100 # multiply values by specific rate of 0.5%
# This below is for the table on the 2nd page
df_belf0005_2 = read_pdf('https://www.belfius.be/imagingservlet/GetDocument?src=mifid&id=TARIFLOANFIDELITY_FR', encoding='ISO-8859-1',
pages=2, stream=True, spreadsheet=True, pandas_options={'header': None})
df_belf0005_2 = df_belf0005_2.drop(df_belf0005_2.index[2:27]) # drop top lines --> USE THIS IF YOU WANNA DROP RANGE
df_belf0005_2.drop(df_belf0005_2.columns[1:3], axis=1, inplace=True) # drop the CAP columns
df_belf0005_2.drop(df_belf0005_2.columns[3], axis=1, inplace=True) # drop the column Rates Mensuel
df_belf0005_2.columns = ["Formulas", "Min", "Max", "Rates"]
df_belf0005_2["Min"] = df_belf0005_2["Min"].str.replace(" mois", "").str.strip() # delete "Mois" in Min and Max
df_belf0005_2["Max"] = df_belf0005_2["Max"].str.replace(" mois", "").str.strip()
df_belf0005_2["Rates"] = df_belf0005_2["Rates"].str.replace(",", ".").str.strip()
df_belf0005_2["Rates"] = df_belf0005_2["Rates"].str.replace(" %", "").str.strip() # delete % so we can calculate below
df_belf0005_2["Rates"] = ((df_belf0005_2["Rates"].astype(float) / 100) + (0.5 / 100)) * 100 # multiply values by specific rate of 0.5%
df_belf0005 = pd.concat([df_belf0005_1, df_belf0005_2])
df_belf0005.insert(0, 'Provider', 'Belfius')
df_belf0005.insert(1, 'Product_ID', 'BELF0005')
df_belf0005.insert(2, 'Category', 'Home Loan')
df_belf0005 = df_belf0005[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BELF0006
df_belf0006 = read_pdf('https://www.belfius.be/imagingservlet/GetDocument?src=mifid&id=TARIFLOANFIDELITY_FR', encoding='ISO-8859-1',
pages=2, stream=True, spreadsheet=True, pandas_options={'header': None})
df_belf0006 = df_belf0006.drop(df_belf0006.index[0:2]) # drop top lines --> USE THIS IF YOU WANNA DROP RANGE
df_belf0006 = df_belf0006.drop(df_belf0006.index[3:26])
df_belf0006.drop(df_belf0006.columns[1:3], axis=1, inplace=True) # drop the CAP columns
df_belf0006.drop(df_belf0006.columns[3], axis=1, inplace=True) # drop the column Rates Mensuel
df_belf0006.columns = ["Formulas", "Min", "Max", "Rates"]
df_belf0006["Min"] = df_belf0006["Min"].str.replace(" mois", "").str.strip() # delete "Mois" in Min and Max
df_belf0006["Max"] = df_belf0006["Max"].str.replace(" mois", "").str.strip()
df_belf0006["Rates"] = df_belf0006["Rates"].str.replace(",", ".").str.strip()
df_belf0006["Rates"] = df_belf0006["Rates"].str.replace(" %", "").str.strip() # delete % so we can calculate below
df_belf0006["Rates"] = ((df_belf0006["Rates"].astype(float) / 100) + (0.5 / 100)) * 100 # multiply values by specific rate of 0.5%
df_belf0006.insert(0, 'Provider', 'Belfius')
df_belf0006.insert(1, 'Product_ID', 'BELF0006')
df_belf0006.insert(2, 'Category', 'Home Loan')
df_belf0006 = df_belf0006[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BELF0007
df_belf0007 = read_pdf('https://www.belfius.be/imagingservlet/GetDocument?src=mifid&id=TARIFLOANFIDELITY_FR', encoding='ISO-8859-1',
pages=2, stream=True, spreadsheet=True, pandas_options={'header': None})
df_belf0007 = df_belf0007.loc[[5]] # use this to parse one line
df_belf0007.drop(df_belf0007.columns[1:3], axis=1, inplace=True) # drop the CAP columns
df_belf0007.drop(df_belf0007.columns[3], axis=1, inplace=True) # drop the column Rates Mensuel
df_belf0007.columns = ["Formulas", "Min", "Max", "Rates"]
df_belf0007["Min"] = df_belf0007["Min"].str.replace(" mois", "").str.strip() # delete "Mois" in Min and Max
df_belf0007["Max"] = df_belf0007["Max"].str.replace(" mois", "").str.strip()
df_belf0007["Rates"] = df_belf0007["Rates"].str.replace(",", ".").str.strip()
df_belf0007["Rates"] = df_belf0007["Rates"].str.replace(" %", "").str.strip() # delete % so we can calculate below
df_belf0007["Rates"] = ((df_belf0007["Rates"].astype(float) / 100) + (0.5 / 100)) * 100 # multiply values by specific rate of 0.5%
df_belf0007.insert(0, 'Provider', 'Belfius')
df_belf0007.insert(1, 'Product_ID', 'BELF0007')
df_belf0007.insert(2, 'Category', 'Home Loan')
df_belf0007 = df_belf0007[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BELF0008
df_belf0008 = read_pdf('https://www.belfius.be/imagingservlet/GetDocument?src=mifid&id=TARIFLOANFIDELITY_FR', encoding='ISO-8859-1',
pages=2, stream=True, spreadsheet=True, pandas_options={'header': None})
df_belf0008 = df_belf0008.loc[[6]] # use this to parse one line
df_belf0008.drop(df_belf0008.columns[1:3], axis=1, inplace=True) # drop the CAP columns
df_belf0008.drop(df_belf0008.columns[3], axis=1, inplace=True) # drop the column Rates Mensuel
df_belf0008.columns = ["Formulas", "Min", "Max", "Rates"]
df_belf0008["Min"] = df_belf0008["Min"].str.replace(" mois", "").str.strip() # delete "Mois" in Min and Max
df_belf0008["Max"] = df_belf0008["Max"].str.replace(" mois", "").str.strip()
df_belf0008["Rates"] = df_belf0008["Rates"].str.replace(",", ".").str.strip()
df_belf0008["Rates"] = df_belf0008["Rates"].str.replace(" %", "").str.strip() # delete % so we can calculate below
df_belf0008["Rates"] = ((df_belf0008["Rates"].astype(float) / 100) + (0.5 / 100)) * 100 # multiply values by specific rate of 0.5%
df_belf0008.insert(0, 'Provider', 'Belfius')
df_belf0008.insert(1, 'Product_ID', 'BELF0008')
df_belf0008.insert(2, 'Category', 'Home Loan')
df_belf0008 = df_belf0008[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BELF0009
df_belf0009 = read_pdf('https://www.belfius.be/imagingservlet/GetDocument?src=mifid&id=TARIFLOANFIDELITY_FR', encoding='ISO-8859-1',
pages=2, stream=True, spreadsheet=True, pandas_options={'header': None})
df_belf0009 = df_belf0009.loc[[7]] # use this to parse one line
df_belf0009.drop(df_belf0009.columns[1:3], axis=1, inplace=True) # drop the CAP columns
df_belf0009.drop(df_belf0009.columns[3], axis=1, inplace=True) # drop the column Rates Mensuel
df_belf0009.columns = ["Formulas", "Min", "Max", "Rates"]
df_belf0009["Min"] = df_belf0009["Min"].str.replace(" mois", "").str.strip() # delete "Mois" in Min and Max
df_belf0009["Max"] = df_belf0009["Max"].str.replace(" mois", "").str.strip()
df_belf0009["Rates"] = df_belf0009["Rates"].str.replace(",", ".").str.strip()
df_belf0009["Rates"] = df_belf0009["Rates"].str.replace(" %", "").str.strip() # delete % so we can calculate below
df_belf0009["Rates"] = ((df_belf0009["Rates"].astype(float) / 100) + (0.5 / 100)) * 100 # multiply values by specific rate of 0.5%
df_belf0009.insert(0, 'Provider', 'Belfius')
df_belf0009.insert(1, 'Product_ID', 'BELF0009')
df_belf0009.insert(2, 'Category', 'Home Loan')
df_belf0009 = df_belf0009[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BELF0010
df_belf0010 = read_pdf('https://www.belfius.be/imagingservlet/GetDocument?src=mifid&id=TARIFLOANFIDELITY_FR', encoding='ISO-8859-1',
pages=2, stream=True, spreadsheet=True, pandas_options={'header': None})
df_belf0010 = df_belf0010.loc[[8]] # use this to parse one line
df_belf0010.drop(df_belf0010.columns[1:3], axis=1, inplace=True) # drop the CAP columns
df_belf0010.drop(df_belf0010.columns[3], axis=1, inplace=True) # drop the column Rates Mensuel
df_belf0010.columns = ["Formulas", "Min", "Max", "Rates"]
df_belf0010["Min"] = df_belf0010["Min"].str.replace(" mois", "").str.strip() # delete "Mois" in Min and Max
df_belf0010["Max"] = df_belf0010["Max"].str.replace(" mois", "").str.strip()
df_belf0010["Rates"] = df_belf0010["Rates"].str.replace(",", ".").str.strip()
df_belf0010["Rates"] = df_belf0010["Rates"].str.replace(" %", "").str.strip() # delete % so we can calculate below
df_belf0010["Rates"] = ((df_belf0010["Rates"].astype(float) / 100) + (0.5 / 100)) * 100 # multiply values by specific rate of 0.5%
df_belf0010.insert(0, 'Provider', 'Belfius')
df_belf0010.insert(1, 'Product_ID', 'BELF0010')
df_belf0010.insert(2, 'Category', 'Home Loan')
df_belf0010 = df_belf0010[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# Concatenate
global belf_c
belf_c = pd.concat([
pd.concat([df_belf0001], axis=1),
pd.concat([df_belf0002], axis=1),
pd.concat([df_belf0003], axis=1),
pd.concat([df_belf0004], axis=1),
pd.concat([df_belf0005], axis=1),
pd.concat([df_belf0006], axis=1),
pd.concat([df_belf0007], axis=1),
pd.concat([df_belf0008], axis=1),
pd.concat([df_belf0009], axis=1),
pd.concat([df_belf0010], axis=1)
])
print(tabulate(belf_c, headers='keys', tablefmt='psql', showindex="never"))
except:
pass
def belfius_save():
belfius()
print(belf_c)
#path = os.path.abspath("History/") # saving file to the folder history
#file_name = str(datetime.datetime.now().strftime("%Y-%m-%d %H.%M")) + '.csv'
#belf_c.to_csv(os.path.join(path, file_name), index=False)
# # ______ ______ ______ _______ _ # #
# # (____ \| ___ \(_____ \ (_______) _ (_) # #
# # ____) ) | | |_____) ) _____ ___ ____| |_ _ ___ # #
# # | __ (| | | | ____/ | ___) _ \ / ___) _)| |/___)# #
# # | |__) ) | | | | | | | |_| | | | |__| |___ |# #
# # |______/|_| |_|_| |_| \___/|_| \___)_(___/ # #
# # # #
def bnpf():
try:
# BNPF0001
df_bnpx0001 = read_pdf('https://www.bnpparibasfortis.be/rsc/contrib/document/1-Website/5-Docserver/BNP/F00015F.pdf', encoding='ISO-8859-1',
pages=2, pandas_options={'header': None})
df_bnpf0001 = df_bnpx0001.drop(df_bnpx0001.index[0:3])
df_bnpf0001 = df_bnpf0001.dropna(axis='columns')
df_bnpf0001 = df_bnpf0001.drop(df_bnpf0001.columns[1], axis=1).drop(df_bnpf0001.columns[3], axis=1)
df_bnpf0001.columns = ["Formulas", "Rates"]
df_bnpf0001["Rates"] = df_bnpf0001["Rates"].str.replace("%", "").str.strip()
df_bnpf0001["Formulas"] = df_bnpf0001["Formulas"].str.replace("é", "e").str.strip()
Min_bnpf0001 = pd.DataFrame({'Min': ['', '', '', '0', '11', '14', '16', '19', '21', '26']})
Max_bnpf0001 = pd.DataFrame({'Max': ['', '', '', '10', '13', '15', '18', '20', '25', '30']})
duration_bnpf0001 = Min_bnpf0001.join(Max_bnpf0001)
df_bnpf0001.insert(0, 'Provider', 'BNPF')
df_bnpf0001.insert(1, 'Product_ID', 'BNPF0001')
df_bnpf0001.insert(2, 'Category', 'Home Loan')
df_bnpf0001 = df_bnpf0001.join(duration_bnpf0001) # join newly made df with existed df
df_bnpf0001 = df_bnpf0001[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BNPF0002
df_bnpx0002 = read_pdf('https://www.bnpparibasfortis.be/rsc/contrib/document/1-Website/5-Docserver/BNP/F00015F.pdf', encoding='ISO-8859-1',
pages=1, pandas_options={'header': None})
df_bnpf0002 = df_bnpx0002.drop(df_bnpx0002.index[0:5]).drop(df_bnpx0002.index[10:19])
df_bnpf0002 = df_bnpf0002.dropna(axis='columns')
df_bnpf0002 = df_bnpf0002.drop(df_bnpf0002.columns[0], axis=1)
df_bnpf0002.columns = ["Rates"]
df_bnpf0002["Rates"] = df_bnpf0002["Rates"].str.replace("%", "").str.strip()
df_bnpf0002["Formulas"] = ['1/1 +3/-3 Indice A (duree ≤ 10ans)', '1/1 +3/-3 Indice A (durée > 10ans et ≤ 15ans)', '1/1 +3/-3 Indice A (durée > 15ans et ≤ 20ans)', '1/1 +3/-3 Indice A (durée > 20ans et ≤ 25ans)', '1/1 +3/-3 Indice A (durée > 25ans et ≤ 30ans)']
Min_bnpf0002 = pd.DataFrame({'Min': [''] * 5 + ['0', '11', '16', '21', '26']})
Max_bnpf0002 = pd.DataFrame({'Max': [''] * 5 + ['10', '15', '20', '25', '30']})
duration_bnpf0002 = Min_bnpf0002.join(Max_bnpf0002)
df_bnpf0002.insert(0, 'Provider', 'BNPF')
df_bnpf0002.insert(1, 'Product_ID', 'BNPF0002')
df_bnpf0002.insert(2, 'Category', 'Home Loan')
df_bnpf0002 = df_bnpf0002.join(duration_bnpf0002) # join newly made df with existed df
df_bnpf0002 = df_bnpf0002[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BNPF0003
df_bnpf0003 = read_pdf('https://www.bnpparibasfortis.be/rsc/contrib/document/1-Website/5-Docserver/BNP/F00015F.pdf', encoding='ISO-8859-1',
pages=1, pandas_options={'header': None})
df_bnpf0003 = df_bnpf0003.drop(df_bnpf0003.index[0:10]).drop(df_bnpf0003.index[11:19])
df_bnpf0003 = df_bnpf0003.dropna(axis='columns')
df_bnpf0003 = df_bnpf0003.drop(df_bnpf0003.columns[0], axis=1)
df_bnpf0003.columns = ["_mens_", "Rates"]
df_bnpf0003.drop('_mens_', axis=1, inplace=True)
df_bnpf0003["Rates"] = df_bnpf0003["Rates"].str.replace("%", "").str.strip()
df_bnpf0003["Formulas"] = ['1/1 +3/-3 Indice A mensualite constante (duree initiale 15 ans)']
Min_bnpf0003 = pd.DataFrame({'Min': [''] * 10 + ['15']})
Max_bnpf0003 = pd.DataFrame({'Max': [''] * 10 + ['25']})
duration_bnpf0003 = Min_bnpf0003.join(Max_bnpf0003)
df_bnpf0003.insert(0, 'Provider', 'BNPF')
df_bnpf0003.insert(1, 'Product_ID', 'BNPF0003')
df_bnpf0003.insert(2, 'Category', 'Home Loan')
df_bnpf0003 = df_bnpf0003.join(duration_bnpf0003) # join newly made df with existed df
df_bnpf0003 = df_bnpf0003[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BNPF0004
df_bnpf0004 = read_pdf('https://www.bnpparibasfortis.be/rsc/contrib/document/1-Website/5-Docserver/BNP/F00015F.pdf', encoding='ISO-8859-1',
pages=1, pandas_options={'header': None})
df_bnpf0004 = df_bnpf0004.drop(df_bnpf0004.index[0:12]).drop(df_bnpf0004.index[13:19])
df_bnpf0004 = df_bnpf0004.dropna(axis='columns')
df_bnpf0004 = df_bnpf0004.drop(df_bnpf0004.columns[0], axis=1)
df_bnpf0004.columns = ["_mens_", "Rates"]
df_bnpf0004.drop('_mens_', axis=1, inplace=True)
df_bnpf0004["Rates"] = df_bnpf0004["Rates"].str.replace("%", "").str.strip()
df_bnpf0004["Formulas"] = ['1/1 +3/-3 Indice A mensualite constante (duree initiale 20 ans)']
Min_bnpf0004 = pd.DataFrame({'Min': [''] * 12 + ['20']})
Max_bnpf0004 = pd.DataFrame({'Max': [''] * 12 + ['25']})
duration_bnpf0004 = Min_bnpf0004.join(Max_bnpf0004)
df_bnpf0004.insert(0, 'Provider', 'BNPF')
df_bnpf0004.insert(1, 'Product_ID', 'BNPF0004')
df_bnpf0004.insert(2, 'Category', 'Home Loan')
df_bnpf0004 = df_bnpf0004.join(duration_bnpf0004) # join newly made df with existed df
df_bnpf0004 = df_bnpf0004[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BNPF0005
df_bnpf0005 = read_pdf('https://www.bnpparibasfortis.be/rsc/contrib/document/1-Website/5-Docserver/BNP/F00015F.pdf', encoding='ISO-8859-1',
pages=1, pandas_options={'header': None})
df_bnpf0005 = df_bnpf0005.drop(df_bnpf0005.index[0:14]).drop(df_bnpf0005.index[15:19])
df_bnpf0005 = df_bnpf0005.dropna(axis='columns')
df_bnpf0005 = df_bnpf0005.drop(df_bnpf0005.columns[0], axis=1)
df_bnpf0005.columns = ["_mens_", "Rates"]
df_bnpf0005.drop('_mens_', axis=1, inplace=True)
df_bnpf0005["Rates"] = df_bnpf0005["Rates"].str.replace("%", "").str.strip()
df_bnpf0005["Formulas"] = ['1/1 +3/-3 Indice A mensualite constante (duree initiale 25 ans)']
Min_bnpf0005 = pd.DataFrame({'Min': [''] * 14 + ['20']})
Max_bnpf0005 = pd.DataFrame({'Max': [''] * 14 + ['25']})
duration_bnpf0005 = Min_bnpf0005.join(Max_bnpf0005)
df_bnpf0005.insert(0, 'Provider', 'BNPF')
df_bnpf0005.insert(1, 'Product_ID', 'BNPF0005')
df_bnpf0005.insert(2, 'Category', 'Home Loan')
df_bnpf0005 = df_bnpf0005.join(duration_bnpf0005) # join newly made df with existed df
df_bnpf0005 = df_bnpf0005[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BNPF0006
df_bnpf0006 = read_pdf('https://www.bnpparibasfortis.be/rsc/contrib/document/1-Website/5-Docserver/BNP/F00015F.pdf', encoding='ISO-8859-1',
pages=1, pandas_options={'header': None})
df_bnpf0006 = df_bnpf0006.drop(df_bnpf0006.index[0:16]).drop(df_bnpf0006.index[17:19])
df_bnpf0006 = df_bnpf0006.dropna(axis='columns')
df_bnpf0006 = df_bnpf0006.drop(df_bnpf0006.columns[0], axis=1)
df_bnpf0006.columns = ["_mens_", "Rates"]
df_bnpf0006.drop('_mens_', axis=1, inplace=True)
df_bnpf0006["Rates"] = df_bnpf0006["Rates"].str.replace("%", "").str.strip()
df_bnpf0006["Formulas"] = ['5/5 +4/-4 indice E']
Min_bnpf0006 = pd.DataFrame({'Min': [''] * 16 + ['10']})
Max_bnpf0006 = pd.DataFrame({'Max': [''] * 16 + ['25']})
duration_bnpf0006 = Min_bnpf0006.join(Max_bnpf0006)
df_bnpf0006.insert(0, 'Provider', 'BNPF')
df_bnpf0006.insert(1, 'Product_ID', 'BNPF0006')
df_bnpf0006.insert(2, 'Category', 'Home Loan')
df_bnpf0006 = df_bnpf0006.join(duration_bnpf0006) # join newly made df with existed df
df_bnpf0006 = df_bnpf0006[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BNPF0007
df_bnpf0007 = read_pdf('https://www.bnpparibasfortis.be/rsc/contrib/document/1-Website/5-Docserver/BNP/F00015F.pdf', encoding='ISO-8859-1',
pages=1, pandas_options={'header': None})
df_bnpf0007 = df_bnpf0007.drop(df_bnpf0007.index[0:17]).drop(df_bnpf0007.index[18:19])
df_bnpf0007 = df_bnpf0007.dropna(axis='columns')
df_bnpf0007 = df_bnpf0007.drop(df_bnpf0007.columns[0], axis=1)
df_bnpf0007.columns = ["_mens_", "Rates"]
df_bnpf0007.drop('_mens_', axis=1, inplace=True)
df_bnpf0007["Rates"] = df_bnpf0007["Rates"].str.replace("%", "").str.strip()
df_bnpf0007["Formulas"] = ['10/5 +2/-5 indice E']
Min_bnpf0007 = pd.DataFrame({'Min': [''] * 17 + ['10']})
Max_bnpf0007 = pd.DataFrame({'Max': [''] * 17 + ['25']})
duration_bnpf0007 = Min_bnpf0007.join(Max_bnpf0007)
df_bnpf0007.insert(0, 'Provider', 'BNPF')
df_bnpf0007.insert(2, 'Category', 'Home Loan')
df_bnpf0007.insert(1, 'Product_ID', 'BNPF0007')
df_bnpf0007 = df_bnpf0007.join(duration_bnpf0007) # join newly made df with existed df
df_bnpf0007 = df_bnpf0007[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# BNPF0008
df_bnpf0008 = read_pdf('https://www.bnpparibasfortis.be/rsc/contrib/document/1-Website/5-Docserver/BNP/F00015F.pdf', encoding='ISO-8859-1',
pages=1, pandas_options={'header': None})
df_bnpf0008 = df_bnpf0008.drop(df_bnpf0008.index[0:18])
df_bnpf0008 = df_bnpf0008.dropna(axis='columns')
df_bnpf0008 = df_bnpf0008.drop(df_bnpf0008.columns[0], axis=1)
df_bnpf0008.columns = ["Rates"]
df_bnpf0008["Rates"] = df_bnpf0008["Rates"].str.replace("%", "").str.strip()
df_bnpf0008["Formulas"] = ['15/5 +2/-5 indice E (duree ≤ 25 ans)']
Min_bnpf0008 = pd.DataFrame({'Min': [''] * 18 + ['15']})
Max_bnpf0008 = pd.DataFrame({'Max': [''] * 18 + ['25']})
duration_bnpf0008 = Min_bnpf0008.join(Max_bnpf0008)
df_bnpf0008.insert(0, 'Provider', 'BNPF')
df_bnpf0008.insert(1, 'Product_ID', 'BNPF0008')
df_bnpf0008.insert(2, 'Category', 'Home Loan')
df_bnpf0008 = df_bnpf0008.join(duration_bnpf0008) # join newly made df with existed df
df_bnpf0008 = df_bnpf0008[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# Concatenate
global bnpf_c
bnpf_c = pd.concat([
pd.concat([df_bnpf0001], axis=1),
pd.concat([df_bnpf0002], axis=1),
pd.concat([df_bnpf0003], axis=1),
pd.concat([df_bnpf0004], axis=1),
pd.concat([df_bnpf0005], axis=1),
pd.concat([df_bnpf0006], axis=1),
pd.concat([df_bnpf0007], axis=1),
pd.concat([df_bnpf0008], axis=1)])
print(tabulate(bnpf_c, headers='keys', tablefmt='psql', showindex="never"))
except:
pass
def bnpf_save():
bnpf()
path = os.path.abspath("History/") # saving file to the folder history
file_name = str(datetime.datetime.now().strftime("%Y-%m-%d %H.%M")) + '.csv'
# Line below is used to concat the whole dfs and save it into a csv file
bnpf_c.to_csv(os.path.join(path, file_name), index=False)
# # ______ ______ ______ # #
# # / _____|____ \ / _____) # #
# # | / ____) ) / # #
# # | | | __ (| | # #
# # | \_____| |__) ) \_____ # #
# # \______)______/ \______) # #
# # # #
def cbc():
try:
# Source
df_cbcx_source1 = read_pdf('https://www.cbc.be/content/dam/particulieren/f-cbc/product/lenen/Wonen/woonkrediet/Carte%20des%20taux%20des%20Cr%C3%A9dits%20logement.pdf', encoding='ISO-8859-1', area=[310, 27.36, 380, 890], pages=1, pandas_options={'header': None})
df_cbcx_source2 = read_pdf('https://www.cbc.be/content/dam/particulieren/f-cbc/product/lenen/Wonen/woonkrediet/Carte%20des%20taux%20des%20Cr%C3%A9dits%20logement.pdf', encoding='ISO-8859-1', area=[290, 1000, 360, 1175], pages=1, pandas_options={'header': None})
df_cbcx_source1.drop(columns=[2,3,4,5,7,8,9,10], inplace=True)
print(df_cbcx_source1)
# CBC0001
## Rate for >25000
df_cbcx0001_1 = df_cbcx_source2.copy()
df_cbcx0001_1.columns = ['Duration', 'Rates']
temp = df_cbcx0001_1['Duration'].str.split('<=', 1).str # split the element within a table
Min = temp[0]
Max = temp[1]
df_cbcx0001_1.insert(1,'Min',Min)
df_cbcx0001_1.insert(2,'Max',Max)
df_cbcx0001_1["Min"] = df_cbcx0001_1["Min"].str.replace(">", "").str.strip()
df_cbcx0001_1["Min"] = df_cbcx0001_1["Min"].str.replace("et", "").str.strip()
df_cbcx0001_1["Max"] = df_cbcx0001_1["Max"].str.replace("ans", "").str.strip()
df_cbcx0001_1.insert(0, "Formulas", "Fixed rate > 25000")
df_cbcx0001_1["Rates"] = df_cbcx0001_1["Rates"].str.replace(",", ".").str.strip()
df_cbcx0001_1.drop('Duration', axis=1, inplace = True)
## Rate for <25000
df_cbcx0001_2 = df_cbcx_source2.copy()
df_cbcx0001_2.columns = ['Duration', 'Rates']
temp = df_cbcx0001_2['Duration'].str.split('<=', 1).str # split the element within a table
Min = temp[0]
Max = temp[1]
df_cbcx0001_2.insert(1,'Min',Min)
df_cbcx0001_2.insert(2,'Max',Max)
df_cbcx0001_2["Min"] = df_cbcx0001_2["Min"].str.replace(">", "").str.strip()
df_cbcx0001_2["Min"] = df_cbcx0001_2["Min"].str.replace("et", "").str.strip()
df_cbcx0001_2["Max"] = df_cbcx0001_2["Max"].str.replace("ans", "").str.strip()
df_cbcx0001_2.insert(0, "Formulas", "Fixed rate < 25000")
df_cbcx0001_2["Rates"] = df_cbcx0001_2["Rates"].str.replace(",", ".").str.strip()
df_cbcx0001_2.drop('Duration', axis=1, inplace = True)
df_cbcx0001_2["Rates"] = ((df_cbcx0001_2["Rates"].astype(float) / 100) + (0.25 / 100)) * 100
##Concatenate rates for >25000 and <25000
df_cbcx0001_1.columns = df_cbcx0001_2.columns
data_cbcx0001 = pd.concat([df_cbcx0001_1, df_cbcx0001_2])
data_cbcx0001.insert(0, 'Provider', 'CBC')
data_cbcx0001.insert(1, 'Product_ID', 'CBC0001')
data_cbcx0001.insert(2, 'Category', 'Home Loan')
data_cbcx0001 = data_cbcx0001[['Provider', 'Product_ID', 'Category', 'Formulas', 'Min', 'Max', 'Rates']] # Change order of columns
# CBC0002
## Rate for >25000
df_cbcx0002_1 = df_cbcx_source1.drop([6,11],axis=1)
df_cbcx0002_1.columns = ["Max", "Rates"]
df_cbcx0002_1.insert(0, "Formulas", "1/1/1 > 25000")
df_cbcx0002_1["Max"] = df_cbcx0002_1["Max"].str.replace("ans", "").str.strip()
df_cbcx0002_1["Max"] = df_cbcx0002_1["Max"].str.replace("<=", "").str.strip()
df_cbcx0002_1["Rates"] = df_cbcx0002_1["Rates"].str.replace(",", ".").str.strip()
df_cbcx0002_1.insert(1, 'Min', [0,11,16,21])
## Rate for <25000
df_cbcx0002_2 = df_cbcx_source1.drop([6,11],axis=1)
df_cbcx0002_2.columns = ["Max", "Rates"]
df_cbcx0002_2.insert(0, "Formulas", "1/1/1 < 25000")
df_cbcx0002_2["Max"] = df_cbcx0002_2["Max"].str.replace("ans", "").str.strip()
df_cbcx0002_2["Max"] = df_cbcx0002_2["Max"].str.replace("<=", "").str.strip()
df_cbcx0002_2["Rates"] = df_cbcx0002_2["Rates"].str.replace(",", ".").str.strip()
df_cbcx0002_2.insert(1, 'Min', [0,11,16,21])