-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPizzaPercentilesNew.py
1363 lines (1214 loc) · 75.8 KB
/
PizzaPercentilesNew.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
import streamlit as st
st.set_page_config(layout="wide")
import pandas as pd
from highlight_text import ax_text,fig_text
import mplsoccer
import matplotlib.pyplot as plt
from scipy import stats
import seaborn as sns
from highlight_text import ax_text,fig_text
from PIL import Image
import imageio
from mplsoccer import PyPizza, add_image, FontManager
import math
import warnings
warnings.filterwarnings('ignore')
header = st.container()
with header:
st.title("HoM Data Visualisation Tool")
st.text("Please use this tool to create your own data visualisation for specific players")
st.text("Created by Liam Henshaw on behalf of Heart of Midlothian Football Club")
with st.expander('Instructions - Please drop down and read'):
st.write('''
1.) Use the filters on the left side of the page to select the league, position, minimum minutes played, and maximum age of players in the data set.\n
2.) This will determine the sample size of players that percentile ratings will generate for.\n
3.) To create your visual, confirm the player you want to see by inputting or copy & pasting the player's name, team and age into the text boxes below.\n
4.) To save your visual, right click and save as.\n
''')
dataset = st.container()
####################################################################################
#Do not change these inputs unless you want to edit the text or background colour
text_color = 'black'
background='white'
##################################################################
df = pd.read_parquet('https://raw.githubusercontent.com/HenshawAnalysis/Wyscout_Streamlit/main/Wyscout_League_Export_Small.parquet')
df = df.dropna(subset=['Position','Team within selected timeframe', 'Age']).reset_index(drop=True)
with st.sidebar:
st.header('Filters')
league = st.selectbox('League', ("Albania Superiore League 2022-23", "Albania Superiore League 2023-24", "Argentina Primera Division 2022", "Argentina Primera Division 2023", "Australia A-League 2022-23", "Austria Bundesliga 2022-23", "Austria Bundesliga 2023-24", "Belarus Premier League 2022", "Belgium First Division A 2022-23", "Belgium First Division B 2022-23", "Belgium First Division B 2023-24", "Bolivia Primera Division 2023", "Bosnia Premijer Liga 2022-23", "Bosnia Premijer Liga 2023-24", "Brazil Serie A 2022", "Brazil Serie A 2023", "Brazil Serie B 2022", "Brazil Serie B 2023", "Bulgaria First League 2022-23", "Bulgaria First League 2023-24", "Canada Premier League 2023", "Chile Primera Division 2023", "China Super League 2023", "Colombia Primera A 2022", "Colombia Primera A 2023", "Costa Rica Primera Division 2022-23", "Costa Rica Primera Division 2023-24", "Croatia 1.HNL 2022-23", "Cyprus First Division 2022-23", "Cyprus First Division 2023-24", "Czech Fortuna Liga 2022-23", "Czech Fortuna Liga 2023-24", "Denmark 1st Division 2022-23", "Denmark 1st Division 2023-24", "Denmark Superliga 2022-23", "Ecuador Serie A 2022", "Ecuador Serie A 2023", "Egypt Premier League 2022-23", "England Championship 2022-23", "England Championship 2023-24", "England League One 2022-23", "England League Two 2022-23", "England National League 2022-23", "England National League North South 2022-23", "England Premier League 2022-23", "England Premier League 2023-24", "Estonia Meistriliiga 2022", "Estonia Meistriliiga 2023", "Finland Veikkausliiga 2022", "Finland Veikkausliiga 2023", "Finland Ykkönen 2023", "France Ligue 1 2022-23", "France Ligue 1 2023-24", "France Ligue 2 2022-23", "Georgia Erovnuli Liga 2022", "Georgia Erovnuli Liga 2023", "Germany 2. Bundesliga 2022-23", "Germany 2. Bundesliga 2023-24", "Germany Bundesliga 2022-23", "Germany Bundesliga 2023-24", "Greece Super League 2022-23", "Greece Super League 2023-24", "Hungary NB1 2022-23", "Hungary NB1 2023-24", "Indonesia Liga 1 2022-23", "Indonesia Liga 1 2023-24", "Ireland Premier Division 2022", "Israel Ligat Ha'Al 2022-23", "Italy Campionato Primavera 1 2022-23", "Italy Serie A 2022-23", "Italy Serie A 2023-24", "Italy Serie B 2022-23", "Italy Serie B 2023-24", "Japan J1-League 2022", "Japan J2-League 2022", "Japan J2-League 2023", "Korea K-League 1 2022", "Korea K-League 2 2022", "Korea K-League 2 2023", "Latvia Virsliga 2022", "Latvia Virsliga 2023", "Malaysia Super League 2023", "Mexico Liga MX 2022-23", "Mexico Liga MX 2023-24", "Mexico Liga de Expansion 2022-23", "Mexico Liga de Expansion 2023-24", "Morocco Botola Pro 2022-23", "Netherlands Eerste Divisie 2022-23", "Netherlands Eerste Divisie 2023-24", "Netherlands Eredivisie 2022-23", "Netherlands Eredivisie 2023-24", "Northern Ireland Premiership 2022-23", "Northern Ireland Premiership 2023-24", "Norway Eliteserien 2022", "Norway First Division 2023", "Paraguay Primera Division 2023", "Peru Primera Division 2023", "Poland 1 Liga 2022-23", "Poland 1 Liga 2023-24", "Poland Ekstraklasa 2022-23", "Portugal Primeira Liga 2022-23", "Portugal Primeira Liga 2023-24", "Portugal Segunda Liga 2022-23", "Portugal Segunda Liga 2023-24", "Qatar Stars League 2022-23", "Romania SuperLiga 2022-23", "Romania SuperLiga 2023-24", "Russia Premier League 2022-23", "Russia Premier League 2023-24", "Scotland Championship 2022-23", "Scotland Championship 2023-24", "Scotland League One 2022-23", "Scotland League One 2023-24", "Scotland League Two 2022-23", "Scotland League Two 2023-24", "Scotland Premiership 2022-23", "Serbia Super Liga 2022-23", "Slovakia Super Liga 2022-23", "Slovenia Prva Liga 2022-23", "Slovenia Prva Liga 2023-24", "South Africa PSL 2022-23", "Spain La Liga 2022-23", "Spain La Liga 2023-24", "Spain Primera Division RFEF 2022-23", "Spain Segunda 2022-23", "Spain Segunda 2023-24", "Sweden Allsvenskan 2022", "Switzerland Super League 2022-23", "Turkey Super Lig 2022-23", "Turkey Super Lig 2023-24", "USA MLS Next Pro 2022", "USA MLS Next Pro 2023", "USA USL Championship 2023", "Ukraine Premier League 2022-23", "Ukraine Premier League 2023-24", "Uruguay Primera Division 2022", "Uruguay Primera Division 2023", "Uzbekistan Super League 2022", "Uzbekistan Super League 2023", "Venezuela Primera Division 2022",))
pos = st.selectbox('Position', ('Centre Back', 'Fullback & Wingback', 'Midfielder', 'Attacking Midfielder & Winger', 'Striker', 'Striker & Wide Forward'))
template = pos
mins = st.number_input('Minimum Minutes Played', 300, max(df['Minutes played'].astype(int)), 500)
maxage = st.slider('Max Age', 15, max(df.Age.astype(int)), 56)
#####################################################################
#Creating Touches "Proxy" - Only If It Is Needed
df['90s'] = df['Minutes played'] /90
df['Passes'] = df['Passes per 90'] * df['90s']
df['Received passes'] = df['Received passes per 90'] * df['90s']
df['Interceptions'] = df['Interceptions per 90'] * df['90s']
df['Sliding tackles'] = df['Sliding tackles per 90'] * df['90s']
df['Dribbles'] = df['Dribbles per 90'] * df['90s']
df = df.round({'Passes': 0})
df = df.round({'Received passes': 0})
df = df.round({'Interceptions': 0})
df = df.round({'Sliding tackles': 0})
df = df.round({'Dribbles': 0})
df['Touches'] = df['Passes'] + df['Received passes'] + df['Interceptions'] + df['Sliding tackles'] + df['Dribbles']
#############################################################################
#Create any additonal metrics you want to use here
#NPxG
df['PenoxG'] = df['Penalties taken'] * 0.76
df['NPxG'] = df['xG'] - df['PenoxG']
df['NPxG per 90'] = df['NPxG'] / df['Minutes played'] * 90
df = df.round({'NPxG per 90': 2})
#xG per shot
df['Total Shots'] = df['Shots']
df['xG/Shot'] = df['NPxG'] / df['Total Shots']
df = df.round({'xG/Shot': 2})
#xA per 100 passes
df['90s'] = df['Minutes played'] /90
df['Total passes'] = df['Passes per 90'] * df['90s']
df['100 passes'] = df['Total passes'] / 100
df['xA per 100 passes'] = df['xA'] / df['100 passes']
df = df.round({'xA per 100 passes': 2})
#Succesful progressive passes
df['Successful progressive passes'] = df['Accurate progressive passes, %'] /100 * df['Progressive passes per 90']
df = df.round({'Successful progressive passes': 2})
#Succesful final third passes
df['Successful final third passes'] = df['Accurate passes to final third, %'] /100 * df['Passes to final third per 90']
df = df.round({'Successful final third passes': 2})
#Defensive duels per touch
df['Defensive Duels'] = df['Defensive duels per 90'] * df['90s']
df['Defensive Duels Per Touch'] = df['Defensive Duels'] / df['Touches']
df = df.round({'Defensive Duels Per Touch': 4})
#Successful Defensive Actions duels per touch
df['Succ Defensive Actions'] = df['Successful defensive actions per 90'] * df['90s']
df['Successful Defensive Actions Per Touch'] = df['Succ Defensive Actions'] / df['Touches']
df = df.round({'Successful Defensive Actions Per Touch': 4})
#PAdj Tackles and Interceptions
df['PAdj Tackles & Interceptions'] = df['PAdj Sliding tackles'] + df['PAdj Interceptions']
#Successul crosses
df['Successful crosses'] = df['Accurate crosses, %'] /100 * df['Crosses per 90']
df = df.round({'Successful crosses': 2})
#Smart passes
df['Smart passes'] = df['Accurate smart passes, %'] /100 * df['Smart passes per 90']
df = df.round({'Smart passes': 2})
#Successul dribbles
df['Successful dribbles'] = df['Successful dribbles, %'] /100 * df['Dribbles per 90']
df = df.round({'Successful dribbles': 2})
#Removing any data with no values from Position, Team and Age
df = df.dropna(subset=['Position', 'Team within selected timeframe', 'Age']).reset_index(drop=True)
#Getting the player's main position
df['Main Position'] = ''
for i in range(len(df)):
df['Main Position'][i] = df['Position'][i].split()[0]
#############################################################################################################################
# Filter data
dfPlayers = df[(df['Minutes played']>=mins) & (df['League']==league) & (df['Age']<=maxage)].copy()
if pos == 'Centre Back':
dfPlayers = dfPlayers[(dfPlayers['Main Position'].str.contains('B'))]
dfPlayers = dfPlayers[~dfPlayers['Main Position'].str.contains('WB')]
dfPlayers = dfPlayers[~dfPlayers['Main Position'].str.contains('RB')]
dfPlayers = dfPlayers[~dfPlayers['Main Position'].str.contains('LB')]
if pos == 'Fullback & Wingback':
dfPlayers = dfPlayers[(dfPlayers['Main Position'].str.contains('LB')) |
(dfPlayers['Main Position'].str.contains('RB')) |
(dfPlayers['Main Position'].str.contains('WB'))]
if pos == 'Midfielder':
dfPlayers = dfPlayers[(dfPlayers['Main Position'].str.contains('CMF')) |
(dfPlayers['Main Position'].str.contains('DMF'))]
if pos == 'Attacking Midfielder & Winger':
dfPlayers = dfPlayers[(dfPlayers['Main Position'].str.contains('AMF')) |
(dfPlayers['Main Position'].str.contains('WF')) |
(dfPlayers['Main Position'].str.contains('LAMF')) |
(dfPlayers['Main Position'].str.contains('RAMF')) |
(dfPlayers['Main Position'].str.contains('LW')) |
(dfPlayers['Main Position'].str.contains('RW'))]
dfPlayers = dfPlayers[~dfPlayers['Main Position'].str.contains('WB')]
if pos == 'Striker':
dfPlayers = dfPlayers[(dfPlayers['Main Position'].str.contains('CF'))]
if pos == 'Striker & Wide Forward':
dfPlayers = dfPlayers[(dfPlayers['Main Position'].str.contains('CF')) |
(dfPlayers['Main Position'].str.contains('RW')) |
(dfPlayers['Main Position'].str.contains('LW'))]
dfPlayers = dfPlayers[~dfPlayers['Main Position'].str.contains('WB')]
#############################################################################
dftable = dfPlayers
dfPercentiles = dfPlayers
dfPlayers = dfPlayers.reset_index(drop=True)
#Setting up templates using the metrics you want
#############################################################################
#Centre Back Template
if template == 'Centre Back':
dfPlayers = dfPlayers[["Player",'Team within selected timeframe', 'Age', 'Minutes played',
"NPxG per 90","Offensive duels per 90","Offensive duels won, %",
'Progressive runs per 90',"Successful progressive passes","Accurate passes, %",
'Accurate forward passes, %', "Forward passes per 90","Successful defensive actions per 90",
'Defensive duels per 90',"Defensive duels won, %","Aerial duels per 90",
"Aerial duels won, %", "Shots blocked per 90", "PAdj Tackles & Interceptions",]]
#Renaming metrics until all metrics
dfPlayers.rename(columns={"NPxG per 90": "Non-penalty xG",
"Non-penalty goals per 90": "Non-penalty goals",
"Shots per 90": "Shots",
"xG/Shot": "xG/Shot",
"Goal conversion, %": "Goal conversion %",
"Offensive duels per 90": "Offensive duels",
"Offensive duels won, %": "Offensive duel\nsuccess %",
"Progressive runs per 90": "Progressive runs",
"Successful progressive passes": "Progressive passes",
"Accurate passes, %": "Pass completion",
"Accurate forward passes, %": "Forward pass\ncompletion",
"Forward passes per 90": "Forward passes",
"Successful defensive actions per 90": "Successful\ndefensive actions",
"Defensive duels per 90": "Defensive duels",
"Defensive duels won, %": "Defensive duel\nsuccess %",
"Aerial duels per 90": "Aerial duels",
"Aerial duels won, %": "Aerial duel\nsuccess %",
"Shots blocked per 90": "Shots blocked",
"PAdj Tackles & Interceptions": "PAdj tackles\n& interceptions",
"Successful crosses": "Successful crosses",
"Successful dribbles": "Successful dribbles",
"Touches in box per 90": "Attacking box\ntouches",
"xA per 100 passes": "xA per 100\npasses",
"Key passes per 90": "Key passes",
"Deep completions per 90": "Deep completions"
}, inplace=True)
#############################################################################
#Fullback & Wingback Template
if template == 'Fullback & Wingback':
dfPlayers = dfPlayers[["Player",'Team within selected timeframe', 'Age', 'Minutes played',
"Successful crosses","Successful dribbles", "Offensive duels per 90",
"Offensive duels won, %","Touches in box per 90",'Progressive runs per 90',
"Successful progressive passes","Accurate passes, %",
'xA per 100 passes', "Key passes per 90",'Defensive duels per 90',
"Defensive duels won, %","Aerial duels per 90",
"Aerial duels won, %", "PAdj Tackles & Interceptions",]]
#Renaming metrics until all metrics
dfPlayers.rename(columns={"NPxG per 90": "Non-penalty xG",
"Non-penalty goals per 90": "Non-penalty goals",
"Shots per 90": "Shots",
"xG/Shot": "xG/Shot",
"Goal conversion, %": "Goal conversion %",
"Offensive duels per 90": "Offensive duels",
"Offensive duels won, %": "Offensive duel\nsuccess %",
"Progressive runs per 90": "Progressive runs",
"Successful progressive passes": "Progressive passes",
"Accurate passes, %": "Pass completion",
"Accurate forward passes, %": "Forward pass\ncompletion",
"Forward passes per 90": "Forward passes",
"Successful defensive actions per 90": "Successful\ndefensive actions",
"Defensive duels per 90": "Defensive duels",
"Defensive duels won, %": "Defensive duel\nsuccess %",
"Aerial duels per 90": "Aerial duels",
"Aerial duels won, %": "Aerial duel\nsuccess %",
"Shots blocked per 90": "Shots blocked",
"PAdj Tackles & Interceptions": "PAdj tackles\n& interceptions",
"Successful crosses": "Successful crosses",
"Successful dribbles": "Successful dribbles",
"Touches in box per 90": "Attacking box\ntouches",
"xA per 100 passes": "xA per 100\npasses",
"Key passes per 90": "Key passes",
"Deep completions per 90": "Deep completions"
}, inplace=True)
#############################################################################
#Midfielder Template
if template == 'Midfielder':
dfPlayers = dfPlayers[["Player",'Team within selected timeframe', 'Age', 'Minutes played',
"NPxG per 90","Shots per 90","Progressive runs per 90",
"Successful progressive passes","Accurate passes, %",
'Accurate forward passes, %', "Forward passes per 90",'xA per 100 passes',
"Key passes per 90", "Deep completions per 90",'Defensive duels per 90',
"Defensive duels won, %","Aerial duels per 90",
"Aerial duels won, %", "PAdj Tackles & Interceptions",]]
#Renaming metrics until all metrics
dfPlayers.rename(columns={"NPxG per 90": "Non-penalty xG",
"Non-penalty goals per 90": "Non-penalty goals",
"Shots per 90": "Shots",
"xG/Shot": "xG/Shot",
"Goal conversion, %": "Goal conversion %",
"Offensive duels per 90": "Offensive duels",
"Offensive duels won, %": "Offensive duel\nsuccess %",
"Progressive runs per 90": "Progressive runs",
"Successful progressive passes": "Progressive passes",
"Accurate passes, %": "Pass completion",
"Accurate forward passes, %": "Forward pass\ncompletion",
"Forward passes per 90": "Forward passes",
"Successful defensive actions per 90": "Successful\ndefensive actions",
"Defensive duels per 90": "Defensive duels",
"Defensive duels won, %": "Defensive duel\nsuccess %",
"Aerial duels per 90": "Aerial duels",
"Aerial duels won, %": "Aerial duel\nsuccess %",
"Shots blocked per 90": "Shots blocked",
"PAdj Tackles & Interceptions": "PAdj tackles\n& interceptions",
"Successful crosses": "Successful crosses",
"Successful dribbles": "Successful dribbles",
"Touches in box per 90": "Attacking box\ntouches",
"xA per 100 passes": "xA per 100\npasses",
"Key passes per 90": "Key passes",
"Deep completions per 90": "Deep completions"
}, inplace=True)
#############################################################################
#Att Mid & Winger Template
if template == 'Attacking Midfielder & Winger':
dfPlayers = dfPlayers[["Player",'Team within selected timeframe', 'Age', 'Minutes played',
"Non-penalty goals per 90","NPxG per 90","Shots per 90",
'xG/Shot',"Goal conversion, %","Successful crosses","Successful dribbles",
"Offensive duels per 90","Offensive duels won, %","xA per 100 passes",
"Key passes per 90", "Deep completions per 90",'Defensive duels per 90',
"Defensive duels won, %", "PAdj Tackles & Interceptions",]]
#Renaming metrics until all metrics
dfPlayers.rename(columns={"NPxG per 90": "Non-penalty xG",
"Non-penalty goals per 90": "Non-penalty goals",
"Shots per 90": "Shots",
"xG/Shot": "xG/Shot",
"Goal conversion, %": "Goal conversion %",
"Offensive duels per 90": "Offensive duels",
"Offensive duels won, %": "Offensive duel\nsuccess %",
"Progressive runs per 90": "Progressive runs",
"Successful progressive passes": "Progressive passes",
"Accurate passes, %": "Pass completion",
"Accurate forward passes, %": "Forward pass\ncompletion",
"Forward passes per 90": "Forward passes",
"Successful defensive actions per 90": "Successful\ndefensive actions",
"Defensive duels per 90": "Defensive duels",
"Defensive duels won, %": "Defensive duel\nsuccess %",
"Aerial duels per 90": "Aerial duels",
"Aerial duels won, %": "Aerial duel\nsuccess %",
"Shots blocked per 90": "Shots blocked",
"PAdj Tackles & Interceptions": "PAdj tackles\n& interceptions",
"Successful crosses": "Successful crosses",
"Successful dribbles": "Successful dribbles",
"Touches in box per 90": "Attacking box\ntouches",
"xA per 100 passes": "xA per 100\npasses",
"Key passes per 90": "Key passes",
"Deep completions per 90": "Deep completions"
}, inplace=True)
#############################################################################
#Striker Template
if template == 'Striker':
dfPlayers = dfPlayers[["Player",'Team within selected timeframe', 'Age', 'Minutes played',
"Non-penalty goals per 90","NPxG per 90","Shots per 90",
'xG/Shot',"Goal conversion, %","Touches in box per 90",
'Dribbles per 90', "Successful dribbles, %","Offensive duels per 90",
"Offensive duels won, %","xA per 100 passes", "Defensive duels per 90",
"Aerial duels per 90","Aerial duels won, %", "PAdj Tackles & Interceptions",]]
#Renaming metrics until all metrics
dfPlayers.rename(columns={"NPxG per 90": "Non-penalty xG",
"Non-penalty goals per 90": "Non-penalty goals",
"Shots per 90": "Shots",
"xG/Shot": "xG/Shot",
"Goal conversion, %": "Goal conversion %",
"Offensive duels per 90": "Offensive duels",
"Offensive duels won, %": "Offensive duel\nsuccess %",
"Progressive runs per 90": "Progressive runs",
"Successful progressive passes": "Progressive passes",
"Accurate passes, %": "Pass completion",
"Accurate forward passes, %": "Forward pass\ncompletion",
"Forward passes per 90": "Forward passes",
"Successful defensive actions per 90": "Successful\ndefensive actions",
"Defensive duels per 90": "Defensive duels",
"Defensive duels won, %": "Defensive duel\nsuccess %",
"Aerial duels per 90": "Aerial duels",
"Aerial duels won, %": "Aerial duel\nsuccess %",
"Shots blocked per 90": "Shots blocked",
"PAdj Tackles & Interceptions": "PAdj tackles\n& interceptions",
"Successful crosses": "Successful crosses",
"Successful dribbles": "Successful dribbles",
"Touches in box per 90": "Attacking box\ntouches",
"xA per 100 passes": "xA per 100\npasses",
"Key passes per 90": "Key passes",
"Deep completions per 90": "Deep completions",
"Dribbles per 90": "Dribbles attempted",
"Successful dribbles, %": "Dribble success %"
}, inplace=True)
#############################################################################
#Striker Template
if template == 'Striker & Wide Forward':
dfPlayers = dfPlayers[["Player",'Team within selected timeframe', 'Age', 'Minutes played',
"Non-penalty goals per 90","NPxG per 90","Shots per 90",
'xG/Shot',"Goal conversion, %","Touches in box per 90",
'Dribbles per 90', "Successful dribbles, %","Offensive duels per 90",
"Offensive duels won, %","xA per 100 passes", "Defensive duels per 90",
"Aerial duels per 90","Aerial duels won, %", "PAdj Tackles & Interceptions",]]
#Renaming metrics until all metrics
dfPlayers.rename(columns={"NPxG per 90": "Non-penalty xG",
"Non-penalty goals per 90": "Non-penalty goals",
"Shots per 90": "Shots",
"xG/Shot": "xG/Shot",
"Goal conversion, %": "Goal conversion %",
"Offensive duels per 90": "Offensive duels",
"Offensive duels won, %": "Offensive duel\nsuccess %",
"Progressive runs per 90": "Progressive runs",
"Successful progressive passes": "Progressive passes",
"Accurate passes, %": "Pass completion",
"Accurate forward passes, %": "Forward pass\ncompletion",
"Forward passes per 90": "Forward passes",
"Successful defensive actions per 90": "Successful\ndefensive actions",
"Defensive duels per 90": "Defensive duels",
"Defensive duels won, %": "Defensive duel\nsuccess %",
"Aerial duels per 90": "Aerial duels",
"Aerial duels won, %": "Aerial duel\nsuccess %",
"Shots blocked per 90": "Shots blocked",
"PAdj Tackles & Interceptions": "PAdj tackles\n& interceptions",
"Successful crosses": "Successful crosses",
"Successful dribbles": "Successful dribbles",
"Touches in box per 90": "Attacking box\ntouches",
"xA per 100 passes": "xA per 100\npasses",
"Key passes per 90": "Key passes",
"Deep completions per 90": "Deep completions",
"Dribbles per 90": "Dribbles attempted",
"Successful dribbles, %": "Dribble success %"
}, inplace=True)
#############################################################################
#Preview Table
final = dftable[['Player','Team within selected timeframe','Age','League','Main Position','Minutes played','Birth country', 'Contract expires',]]
final = final.loc[(final['League']==league)]
final.Age = final.Age.astype(int)
final.sort_values(by=['Age'], inplace=True)
final = final[final['Age']<=maxage].reset_index(drop=True)
with dataset:
st.write(final)
#############################################################################
st.header("Enter the player's name, team and age to create the visuals")
st.text("Feel free to type the information, or copy and paste it from the table above")
player = st.text_input("Player's Name", "")
team = st.text_input("Player's Team", "")
page = st.number_input("Player's Age", step=1)
#Season - Competition Data Base
complete = ["Albania Superiore League 2022-23", "Albania Superiore League 2023-24", "Argentina Primera Division 2022", "Argentina Primera Division 2023", "Australia A-League 2022-23", "Austria Bundesliga 2022-23", "Austria Bundesliga 2023-24", "Belarus Premier League 2022", "Belgium First Division A 2022-23", "Belgium First Division B 2022-23", "Belgium First Division B 2023-24", "Bolivia Primera Division 2023", "Bosnia Premijer Liga 2022-23", "Bosnia Premijer Liga 2023-24", "Brazil Serie A 2022", "Brazil Serie A 2023", "Brazil Serie B 2022", "Brazil Serie B 2023", "Bulgaria First League 2022-23", "Bulgaria First League 2023-24", "Canada Premier League 2023", "Chile Primera Division 2023", "China Super League 2023", "Colombia Primera A 2022", "Colombia Primera A 2023", "Costa Rica Primera Division 2022-23", "Costa Rica Primera Division 2023-24", "Croatia 1.HNL 2022-23", "Cyprus First Division 2022-23", "Cyprus First Division 2023-24", "Czech Fortuna Liga 2022-23", "Czech Fortuna Liga 2023-24", "Denmark 1st Division 2022-23", "Denmark 1st Division 2023-24", "Denmark Superliga 2022-23", "Ecuador Serie A 2022", "Ecuador Serie A 2023", "Egypt Premier League 2022-23", "England Championship 2022-23", "England Championship 2023-24", "England League One 2022-23", "England League Two 2022-23", "England National League 2022-23", "England National League North South 2022-23", "England Premier League 2022-23", "England Premier League 2023-24", "Estonia Meistriliiga 2022", "Estonia Meistriliiga 2023", "Finland Veikkausliiga 2022", "Finland Veikkausliiga 2023", "Finland Ykkönen 2023", "France Ligue 1 2022-23", "France Ligue 1 2023-24", "France Ligue 2 2022-23", "Georgia Erovnuli Liga 2022", "Georgia Erovnuli Liga 2023", "Germany 2. Bundesliga 2022-23", "Germany 2. Bundesliga 2023-24", "Germany Bundesliga 2022-23", "Germany Bundesliga 2023-24", "Greece Super League 2022-23", "Greece Super League 2023-24", "Hungary NB1 2022-23", "Hungary NB1 2023-24", "Indonesia Liga 1 2022-23", "Indonesia Liga 1 2023-24", "Ireland Premier Division 2022", "Israel Ligat Ha'Al 2022-23", "Italy Campionato Primavera 1 2022-23", "Italy Serie A 2022-23", "Italy Serie A 2023-24", "Italy Serie B 2022-23", "Italy Serie B 2023-24", "Japan J1-League 2022", "Japan J2-League 2022", "Japan J2-League 2023", "Korea K-League 1 2022", "Korea K-League 2 2022", "Korea K-League 2 2023", "Latvia Virsliga 2022", "Latvia Virsliga 2023", "Malaysia Super League 2023", "Mexico Liga MX 2022-23", "Mexico Liga MX 2023-24", "Mexico Liga de Expansion 2022-23", "Mexico Liga de Expansion 2023-24", "Morocco Botola Pro 2022-23", "Netherlands Eerste Divisie 2022-23", "Netherlands Eerste Divisie 2023-24", "Netherlands Eredivisie 2022-23", "Netherlands Eredivisie 2023-24", "Northern Ireland Premiership 2022-23", "Northern Ireland Premiership 2023-24", "Norway Eliteserien 2022", "Norway First Division 2023", "Paraguay Primera Division 2023", "Peru Primera Division 2023", "Poland 1 Liga 2022-23", "Poland 1 Liga 2023-24", "Poland Ekstraklasa 2022-23", "Portugal Primeira Liga 2022-23", "Portugal Primeira Liga 2023-24", "Portugal Segunda Liga 2022-23", "Portugal Segunda Liga 2023-24", "Qatar Stars League 2022-23", "Romania SuperLiga 2022-23", "Romania SuperLiga 2023-24", "Russia Premier League 2022-23", "Russia Premier League 2023-24", "Scotland Championship 2022-23", "Scotland Championship 2023-24", "Scotland League One 2022-23", "Scotland League One 2023-24", "Scotland League Two 2022-23", "Scotland League Two 2023-24", "Scotland Premiership 2022-23", "Serbia Super Liga 2022-23", "Slovakia Super Liga 2022-23", "Slovenia Prva Liga 2022-23", "Slovenia Prva Liga 2023-24", "South Africa PSL 2022-23", "Spain La Liga 2022-23", "Spain La Liga 2023-24", "Spain Primera Division RFEF 2022-23", "Spain Segunda 2022-23", "Spain Segunda 2023-24", "Sweden Allsvenskan 2022", "Switzerland Super League 2022-23", "Turkey Super Lig 2022-23", "Turkey Super Lig 2023-24", "USA MLS Next Pro 2022", "USA MLS Next Pro 2023", "USA USL Championship 2023", "Ukraine Premier League 2022-23", "Ukraine Premier League 2023-24", "Uruguay Primera Division 2022", "Uruguay Primera Division 2023", "Uzbekistan Super League 2022", "Uzbekistan Super League 2023", "Venezuela Primera Division 2022"]
summer = []
winter = []
if league in summer:
ssn_ = ' 2022'
elif league in winter:
ssn_ = ' 2022-23'
elif league in complete:
ssn_ = ''
#############################################################################
pizzadf = dfPlayers
#NEW DATA FRAME FOR YOUR PLAYER / EDIT NAME
pizzaplayer = pizzadf.loc[dfPlayers['Player']==player].reset_index()
#Get the mins played value for specific player needed for visual
minplay = int(pizzaplayer['Minutes played'].values[0])
#Getting just the data values for visual
pizzaplayer = list(pizzaplayer.loc[0])
pizzaplayer = pizzaplayer[5:]
#get parameters
params = list(pizzadf.columns)
#drop the first list team because we don't need player name. Start at first metric
params = params[4:]
#Get Percentiles
values = []
for x in range(len(params)):
values.append(math.floor(stats.percentileofscore(pizzadf[params[x]],pizzaplayer[x])))
#Get Percentiles
values = []
for x in range(len(params)):
values.append(math.floor(stats.percentileofscore(pizzadf[params[x]],pizzaplayer[x])))
#SETTING UP PIZZA
# color for the slices and text for each of the templates
if template == 'Centre Back':
slice_colors = ["#660000"] * 4 + ["#014F8A"] * 4 + ["#5A5A5A"] * 7
text_colors = ["white"] * 15
if template == 'Fullback & Wingback':
slice_colors = ["#660000"] * 6 + ["#014F8A"] * 4 + ["#5A5A5A"] * 5
text_colors = ["white"] * 15
if template == 'Midfielder':
slice_colors = ["#660000"] * 3 + ["#014F8A"] * 7 + ["#5A5A5A"] * 5
text_colors = ["white"] * 15
if template == 'Attacking Midfielder & Winger':
slice_colors = ["#660000"] * 7 + ["#014F8A"] * 5 + ["#5A5A5A"] * 3
text_colors = ["white"] * 15
if template == 'Striker':
slice_colors = ["#660000"] * 6 + ["#014F8A"] * 5 + ["#5A5A5A"] * 4
text_colors = ["white"] * 15
if template == 'Striker & Wide Forward':
slice_colors = ["#660000"] * 6 + ["#014F8A"] * 5 + ["#5A5A5A"] * 4
text_colors = ["white"] * 15
# instantiate PyPizza class
baker = PyPizza(
params=params, # list of parameters
background_color=background, # background color
straight_line_color="#EBEBE9", # color for straight lines
straight_line_lw=1, # linewidth for straight lines
last_circle_lw=0, # linewidth of last circle
other_circle_lw=0, # linewidth for other circles
inner_circle_size=5 # size of inner circle
)
# plot pizza
fig, ax = baker.make_pizza(
values, # list of values
figsize=(10, 10), # adjust figsize according to your need
color_blank_space="same", # use same color to fill blank space
slice_colors=slice_colors, # color for individual slices
value_colors=text_colors, # color for the value-text
value_bck_colors=slice_colors, # color for the blank spaces
blank_alpha=0.4, # alpha for blank-space colors
kwargs_slices=dict(
edgecolor="white", zorder=2, linewidth=1
), # values to be used when plotting slices
kwargs_params=dict(
color="#000000", fontsize=11,
), # values to be used when adding parameter
kwargs_values=dict(
color="white", fontsize=12,
bbox=dict(
edgecolor="white", facecolor="cornflowerblue",
boxstyle="round,pad=0.2", lw=1
)
) # values to be used when adding parameter-values
)
# add title
fig.text(
0.515, 0.975, "%s (%i) - %s\n" %(player, page, team),
size=16, fontweight='bold', ha="center", color="#000000"
)
# add subtitle
fig.text(
0.515, 0.956,
"%i minutes played\nPercentile Rank vs %ss - "%(minplay, template) + league + ssn_,
size=14,
ha="center", color="#000000"
)
# add credits
CREDIT_1 = "Graphic: Liam Henshaw on behalf of Heart of Midlothian FC"
CREDIT_2 = "Template: %s" %(template)
CREDIT_3 = "Notes: All units are per 90mins | Data is via Wyscout | %s+ mins" %(mins)
fig.text(
0.94, 0.000, f"{CREDIT_1}\n{CREDIT_2}\n{CREDIT_3}", size=9,
color="#545454", fontstyle='italic',
ha="right"
)
# add text
fig.text(
0.35, 0.93, "Attacking Possession Defending", size=14,
color="#000000"
)
# add rectangles
fig.patches.extend([
plt.Rectangle(
(0.32, 0.9275), 0.025, 0.021, fill=True, color="#660000",
transform=fig.transFigure, figure=fig
),
plt.Rectangle(
(0.445, 0.9275), 0.025, 0.021, fill=True, color="#014F8A",
transform=fig.transFigure, figure=fig
),
plt.Rectangle(
(0.582, 0.9275), 0.025, 0.021, fill=True, color="#5A5A5A",
transform=fig.transFigure, figure=fig
),
])
im2 = imageio.imread('HeartsLogo.png')
# add image
ax_image = add_image(
im2, fig, left=0.09, bottom=-0.01, width=0.13, height=0.127
) # these values might differ when you are pl
visuals = st.container()
with visuals:
disp1_col , disp2_col = st.columns(2)
disp1_col.pyplot(fig)
#######################################################################################################################
#Renaming Metrics
dfPercentiles['Successful defensive actions'] = dfPercentiles['Successful defensive actions per 90']
dfPercentiles['Defensive duels'] = dfPercentiles['Defensive duels per 90']
dfPercentiles['Defensive duel success %'] = dfPercentiles['Defensive duels won, %']
dfPercentiles['Aerial duels'] = dfPercentiles['Aerial duels per 90']
dfPercentiles['Aerial duel success %'] = dfPercentiles['Aerial duels won, %']
dfPercentiles['Shots blocked'] = dfPercentiles['Shots blocked per 90']
dfPercentiles['PAdj interceptions'] = dfPercentiles['PAdj Interceptions']
dfPercentiles['Successful attacking actions'] = dfPercentiles['Successful attacking actions per 90']
dfPercentiles['Non-penalty xG'] = dfPercentiles['NPxG per 90']
dfPercentiles['Non-penalty goals'] = dfPercentiles['Non-penalty goals per 90']
dfPercentiles['Shots'] = dfPercentiles['Shots per 90']
dfPercentiles['Crosses'] = dfPercentiles['Crosses per 90']
dfPercentiles['Crossing accuracy %'] = dfPercentiles['Accurate crosses, %']
dfPercentiles['Dribbles'] = dfPercentiles['Dribbles per 90']
dfPercentiles['Dribble success %'] = dfPercentiles['Successful dribbles, %']
dfPercentiles['Offensive duels'] = dfPercentiles['Offensive duels per 90']
dfPercentiles['Offensive duel success %'] = dfPercentiles['Offensive duels won, %']
dfPercentiles['Attacking box touches'] = dfPercentiles['Touches in box per 90']
dfPercentiles['Attacking box touches per 90'] = dfPercentiles['Touches in box per 90']
dfPercentiles['Progressive runs'] = dfPercentiles['Progressive runs per 90']
dfPercentiles['Pass completion %'] = dfPercentiles['Accurate passes, %']
dfPercentiles['Forward passes'] = dfPercentiles['Forward passes per 90']
dfPercentiles['Forward pass completion %'] = dfPercentiles['Accurate forward passes, %']
dfPercentiles['Second assists'] = dfPercentiles['Second assists per 90']
dfPercentiles['Key passes'] = dfPercentiles['Key passes per 90']
dfPercentiles['Received passes'] = dfPercentiles['Received passes per 90']
dfPercentiles['Passes to penalty area'] = dfPercentiles['Passes to penalty area per 90']
dfPercentiles['Passes to penalty area success %'] = dfPercentiles['Accurate passes to penalty area, %']
dfPercentiles['Deep completions'] = dfPercentiles['Deep completions per 90']
dfPercentiles['Goal conversion %'] = dfPercentiles['Goal conversion, %']
dfPercentiles['Fouls won'] = dfPercentiles['Fouls suffered per 90']
dfPercentiles['Shots on target %'] = dfPercentiles['Shots on target, %']
dfPercentiles['Shot assists'] = dfPercentiles['Shot assists per 90']
dfPercentiles['Offensive duels success %'] = dfPercentiles['Offensive duels won, %']
dfPercentiles['Progressive passes'] = dfPercentiles['Successful progressive passes']
percentilesdf = dfPercentiles[dfPercentiles["Player"] == player].copy()
#Bar Chart Percentiles
CB1 = "Non-penalty xG"
CB2 = "Offensive duels"
CB3 = "Offensive duels success %"
CB4 = "Successful attacking actions"
CB5 = "Progressive runs"
CB6 = "Progressive passes"
CB7 = "Pass completion %"
CB8 = "Forward pass completion %"
CB9 = "Forward passes"
CB10 = "Successful defensive actions"
CB11 = "Defensive duels"
CB12 = "Defensive duel success %"
CB13 = "Aerial duels"
CB14 = "Aerial duel success %"
CB15 = "Shots blocked"
CB16 = "PAdj interceptions"
FBWB1 = "Non-penalty xG"
FBWB2 = "Shots"
FBWB3 = "Offensive duels"
FBWB4 = "Offensive duels success %"
FBWB5 = "Dribbles"
FBWB6 = "Dribble success %"
FBWB7 = "Crosses"
FBWB8 = "Crossing accuracy %"
FBWB9 = "Attacking box touches"
FBWB10 = "Successful attacking actions"
FBWB11 = "Progressive runs"
FBWB12 = "Progressive passes"
FBWB13 = "xA per 100 passes"
FBWB14 = "Key passes"
FBWB15 = "Second assists"
FBWB16 = "Pass completion %"
FBWB17 = "Forward passes"
FBWB18 = "Forward pass completion %"
FBWB19 = "Passes to penalty area"
FBWB20 = "Passes to penalty area success %"
FBWB21 = "Successful defensive actions"
FBWB22 = "Defensive duels"
FBWB23 = "Defensive duel success %"
FBWB24 = "Aerial duels"
FBWB25 = "Aerial duel success %"
FBWB26 = "Shots blocked"
FBWB27 = "PAdj interceptions"
MID1 = "Non-penalty xG"
MID2 = "Shots"
MID3 = "Offensive duels"
MID4 = "Offensive duels success %"
MID5 = "Dribbles"
MID6 = "Dribble success %"
MID7 = "Attacking box touches"
MID8 = "Successful attacking actions"
MID9 = "Progressive runs"
MID10 = "Progressive passes"
MID11 = "xA per 100 passes"
MID12 = "Key passes"
MID13 = "Second assists"
MID14 = "Smart passes"
MID15 = "Deep completions"
MID16 = "Received passes"
MID17 = "Pass completion %"
MID18 = "Forward passes"
MID19 = "Forward pass completion %"
MID20 = "Passes to penalty area"
MID21 = "Passes to penalty area success %"
MID22 = "Successful defensive actions"
MID23 = "Defensive duels"
MID24 = "Defensive duel success %"
MID25 = "Aerial duels"
MID26 = "Aerial duel success %"
MID27 = "Shots blocked"
MID28 = "PAdj interceptions"
AMW1 = "Non-penalty xG"
AMW2 = "Non-penalty goals"
AMW3 = "Goal conversion %"
AMW4 = "xG/Shot"
AMW5 = "Shots"
AMW6 = "Offensive duels"
AMW7 = "Offensive duels success %"
AMW8 = "Dribbles"
AMW9 = "Dribble success %"
AMW10 = "Attacking box touches"
AMW11 = "Crosses"
AMW12 = "Crossing accuracy %"
AMW13 = "Successful attacking actions"
AMW14 = "Progressive runs"
AMW15 = "Progressive passes"
AMW16 = "Fouls won"
AMW17 = "xA per 100 passes"
AMW18 = "Key passes"
AMW19 = "Second assists"
AMW20 = "Smart passes"
AMW21 = "Deep completions"
AMW22 = "Received passes"
AMW23 = "Pass completion %"
AMW24 = "Forward passes"
AMW25 = "Forward pass completion %"
AMW26 = "Passes to penalty area"
AMW27 = "Passes to penalty area success %"
AMW28 = "Successful defensive actions"
AMW29 = "Defensive duels"
AMW30 = "Defensive duel success %"
AMW31 = "Aerial duels"
AMW32 = "Aerial duel success %"
AMW33 = "Shots blocked"
AMW34 = "PAdj interceptions"
ST1 = "Non-penalty xG"
ST2 = "Non-penalty goals"
ST3 = "Goal conversion %"
ST4 = "Shots on target %"
ST5 = "Shots"
ST6 = "xG/Shot"
ST7 = "Offensive duels"
ST8 = "Offensive duels success %"
ST9 = "Dribbles"
ST10 = "Dribble success %"
ST11 = "Attacking box touches"
ST12 = "Successful attacking actions"
ST13 = "Fouls won"
ST14 = "xA per 100 passes"
ST15 = "Shot assists"
ST16 = "Second assists"
ST17 = "Deep completions"
ST18 = "Received passes"
ST19 = "Successful defensive actions"
ST20 = "Defensive duels"
ST21 = "Defensive duel success %"
ST22 = "Aerial duels"
ST23 = "Aerial duel success %"
ST24 = "PAdj interceptions"
#Get the specific player's value
xCB1 = percentilesdf[CB1].values[0]
xCB2 = percentilesdf[CB2].values[0]
xCB3 = percentilesdf[CB3].values[0]
xCB4 = percentilesdf[CB4].values[0]
xCB5 = percentilesdf[CB5].values[0]
xCB6 = percentilesdf[CB6].values[0]
xCB7 = percentilesdf[CB7].values[0]
xCB8 = percentilesdf[CB8].values[0]
xCB9 = percentilesdf[CB9].values[0]
xCB10 = percentilesdf[CB10].values[0]
xCB11 = percentilesdf[CB11].values[0]
xCB12 = percentilesdf[CB12].values[0]
xCB13 = percentilesdf[CB13].values[0]
xCB14 = percentilesdf[CB14].values[0]
xCB15 = percentilesdf[CB15].values[0]
xCB16 = percentilesdf[CB16].values[0]
xFBWB1 = percentilesdf[FBWB1].values[0]
xFBWB2 = percentilesdf[FBWB2].values[0]
xFBWB3 = percentilesdf[FBWB3].values[0]
xFBWB4 = percentilesdf[FBWB4].values[0]
xFBWB5 = percentilesdf[FBWB5].values[0]
xFBWB6 = percentilesdf[FBWB6].values[0]
xFBWB7 = percentilesdf[FBWB7].values[0]
xFBWB8 = percentilesdf[FBWB8].values[0]
xFBWB9 = percentilesdf[FBWB9].values[0]
xFBWB10 = percentilesdf[FBWB10].values[0]
xFBWB11 = percentilesdf[FBWB11].values[0]
xFBWB12 = percentilesdf[FBWB12].values[0]
xFBWB13 = percentilesdf[FBWB13].values[0]
xFBWB14 = percentilesdf[FBWB14].values[0]
xFBWB15 = percentilesdf[FBWB15].values[0]
xFBWB16 = percentilesdf[FBWB16].values[0]
xFBWB17 = percentilesdf[FBWB17].values[0]
xFBWB18 = percentilesdf[FBWB18].values[0]
xFBWB19 = percentilesdf[FBWB19].values[0]
xFBWB20 = percentilesdf[FBWB20].values[0]
xFBWB21 = percentilesdf[FBWB21].values[0]
xFBWB22 = percentilesdf[FBWB22].values[0]
xFBWB23 = percentilesdf[FBWB23].values[0]
xFBWB24 = percentilesdf[FBWB24].values[0]
xFBWB25 = percentilesdf[FBWB25].values[0]
xFBWB26 = percentilesdf[FBWB26].values[0]
xFBWB27 = percentilesdf[FBWB27].values[0]
xMID1 = percentilesdf[MID1].values[0]
xMID2 = percentilesdf[MID2].values[0]
xMID3 = percentilesdf[MID3].values[0]
xMID4 = percentilesdf[MID4].values[0]
xMID5 = percentilesdf[MID5].values[0]
xMID6 = percentilesdf[MID6].values[0]
xMID7 = percentilesdf[MID7].values[0]
xMID8 = percentilesdf[MID8].values[0]
xMID9 = percentilesdf[MID9].values[0]
xMID10 = percentilesdf[MID10].values[0]
xMID11 = percentilesdf[MID11].values[0]
xMID12 = percentilesdf[MID12].values[0]
xMID13 = percentilesdf[MID13].values[0]
xMID14 = percentilesdf[MID14].values[0]
xMID15 = percentilesdf[MID15].values[0]
xMID16 = percentilesdf[MID16].values[0]
xMID17 = percentilesdf[MID17].values[0]
xMID18 = percentilesdf[MID18].values[0]
xMID19 = percentilesdf[MID19].values[0]
xMID20 = percentilesdf[MID20].values[0]
xMID21 = percentilesdf[MID21].values[0]
xMID22 = percentilesdf[MID22].values[0]
xMID23 = percentilesdf[MID23].values[0]
xMID24 = percentilesdf[MID24].values[0]
xMID25 = percentilesdf[MID25].values[0]
xMID26 = percentilesdf[MID26].values[0]
xMID27 = percentilesdf[MID27].values[0]
xMID28 = percentilesdf[MID28].values[0]
xAMW1 = percentilesdf[AMW1].values[0]
xAMW2 = percentilesdf[AMW2].values[0]
xAMW3 = percentilesdf[AMW3].values[0]
xAMW4 = percentilesdf[AMW4].values[0]
xAMW5 = percentilesdf[AMW5].values[0]
xAMW6 = percentilesdf[AMW6].values[0]
xAMW7 = percentilesdf[AMW7].values[0]
xAMW8 = percentilesdf[AMW8].values[0]
xAMW9 = percentilesdf[AMW9].values[0]
xAMW10 = percentilesdf[AMW10].values[0]
xAMW11 = percentilesdf[AMW11].values[0]
xAMW12 = percentilesdf[AMW12].values[0]
xAMW13 = percentilesdf[AMW13].values[0]
xAMW14 = percentilesdf[AMW14].values[0]
xAMW15 = percentilesdf[AMW15].values[0]
xAMW16 = percentilesdf[AMW16].values[0]
xAMW17 = percentilesdf[AMW17].values[0]
xAMW18 = percentilesdf[AMW18].values[0]
xAMW19 = percentilesdf[AMW19].values[0]
xAMW20 = percentilesdf[AMW20].values[0]
xAMW21 = percentilesdf[AMW21].values[0]
xAMW22 = percentilesdf[AMW22].values[0]
xAMW23 = percentilesdf[AMW23].values[0]
xAMW24 = percentilesdf[AMW24].values[0]
xAMW25 = percentilesdf[AMW25].values[0]
xAMW26 = percentilesdf[AMW26].values[0]
xAMW27 = percentilesdf[AMW27].values[0]
xAMW28 = percentilesdf[AMW28].values[0]
xAMW29 = percentilesdf[AMW29].values[0]
xAMW30 = percentilesdf[AMW30].values[0]
xAMW31 = percentilesdf[AMW31].values[0]
xAMW32 = percentilesdf[AMW32].values[0]
xAMW33 = percentilesdf[AMW33].values[0]
xAMW34 = percentilesdf[AMW34].values[0]
xST1 = percentilesdf[ST1].values[0]
xST2 = percentilesdf[ST2].values[0]
xST3 = percentilesdf[ST3].values[0]
xST4 = percentilesdf[ST4].values[0]
xST5 = percentilesdf[ST5].values[0]
xST6 = percentilesdf[ST6].values[0]
xST7 = percentilesdf[ST7].values[0]
xST8 = percentilesdf[ST8].values[0]
xST9 = percentilesdf[ST9].values[0]
xST10 = percentilesdf[ST10].values[0]
xST11 = percentilesdf[ST11].values[0]
xST12 = percentilesdf[ST12].values[0]
xST13 = percentilesdf[ST13].values[0]
xST14 = percentilesdf[ST14].values[0]
xST15 = percentilesdf[ST15].values[0]
xST16 = percentilesdf[ST16].values[0]
xST17 = percentilesdf[ST17].values[0]
xST18 = percentilesdf[ST18].values[0]
xST19 = percentilesdf[ST19].values[0]
xST20 = percentilesdf[ST20].values[0]
xST21 = percentilesdf[ST21].values[0]
xST22 = percentilesdf[ST22].values[0]
xST23 = percentilesdf[ST23].values[0]
xST24 = percentilesdf[ST24].values[0]
###############################################################################################
pct1CB = stats.percentileofscore(dfPercentiles[CB1],xCB1)
pct2CB = stats.percentileofscore(dfPercentiles[CB2],xCB2)
pct3CB = stats.percentileofscore(dfPercentiles[CB3],xCB3)
pct4CB = stats.percentileofscore(dfPercentiles[CB4],xCB4)
pct5CB = stats.percentileofscore(dfPercentiles[CB5],xCB5)
pct6CB = stats.percentileofscore(dfPercentiles[CB6],xCB6)
pct7CB = stats.percentileofscore(dfPercentiles[CB7],xCB7)
pct8CB = stats.percentileofscore(dfPercentiles[CB8],xCB8)
pct9CB = stats.percentileofscore(dfPercentiles[CB9],xCB9)
pct10CB = stats.percentileofscore(dfPercentiles[CB10],xCB10)
pct11CB = stats.percentileofscore(dfPercentiles[CB11],xCB11)
pct12CB = stats.percentileofscore(dfPercentiles[CB12],xCB12)
pct13CB = stats.percentileofscore(dfPercentiles[CB13],xCB13)
pct14CB = stats.percentileofscore(dfPercentiles[CB14],xCB14)
pct15CB = stats.percentileofscore(dfPercentiles[CB15],xCB15)
pct16CB = stats.percentileofscore(dfPercentiles[CB16],xCB16)
pct1FBWB = stats.percentileofscore(dfPercentiles[FBWB1],xFBWB1)
pct2FBWB = stats.percentileofscore(dfPercentiles[FBWB2],xFBWB2)
pct3FBWB = stats.percentileofscore(dfPercentiles[FBWB3],xFBWB3)
pct4FBWB = stats.percentileofscore(dfPercentiles[FBWB4],xFBWB4)
pct5FBWB = stats.percentileofscore(dfPercentiles[FBWB5],xFBWB5)
pct6FBWB = stats.percentileofscore(dfPercentiles[FBWB6],xFBWB6)
pct7FBWB = stats.percentileofscore(dfPercentiles[FBWB7],xFBWB7)
pct8FBWB = stats.percentileofscore(dfPercentiles[FBWB8],xFBWB8)
pct9FBWB = stats.percentileofscore(dfPercentiles[FBWB9],xFBWB9)
pct10FBWB = stats.percentileofscore(dfPercentiles[FBWB10],xFBWB10)
pct11FBWB = stats.percentileofscore(dfPercentiles[FBWB11],xFBWB11)
pct12FBWB = stats.percentileofscore(dfPercentiles[FBWB12],xFBWB12)
pct13FBWB = stats.percentileofscore(dfPercentiles[FBWB13],xFBWB13)
pct14FBWB = stats.percentileofscore(dfPercentiles[FBWB14],xFBWB14)
pct15FBWB = stats.percentileofscore(dfPercentiles[FBWB15],xFBWB15)
pct16FBWB = stats.percentileofscore(dfPercentiles[FBWB16],xFBWB16)
pct17FBWB = stats.percentileofscore(dfPercentiles[FBWB17],xFBWB17)
pct18FBWB = stats.percentileofscore(dfPercentiles[FBWB18],xFBWB18)
pct19FBWB = stats.percentileofscore(dfPercentiles[FBWB19],xFBWB19)
pct20FBWB = stats.percentileofscore(dfPercentiles[FBWB20],xFBWB20)
pct21FBWB = stats.percentileofscore(dfPercentiles[FBWB21],xFBWB21)
pct22FBWB = stats.percentileofscore(dfPercentiles[FBWB22],xFBWB22)
pct23FBWB = stats.percentileofscore(dfPercentiles[FBWB23],xFBWB23)
pct24FBWB = stats.percentileofscore(dfPercentiles[FBWB24],xFBWB24)
pct25FBWB = stats.percentileofscore(dfPercentiles[FBWB25],xFBWB25)
pct26FBWB = stats.percentileofscore(dfPercentiles[FBWB26],xFBWB26)
pct27FBWB = stats.percentileofscore(dfPercentiles[FBWB27],xFBWB27)
pct1MID = stats.percentileofscore(dfPercentiles[MID1],xMID1)
pct2MID = stats.percentileofscore(dfPercentiles[MID2],xMID2)
pct3MID = stats.percentileofscore(dfPercentiles[MID3],xMID3)
pct4MID = stats.percentileofscore(dfPercentiles[MID4],xMID4)
pct5MID = stats.percentileofscore(dfPercentiles[MID5],xMID5)
pct6MID = stats.percentileofscore(dfPercentiles[MID6],xMID6)
pct7MID = stats.percentileofscore(dfPercentiles[MID7],xMID7)
pct8MID = stats.percentileofscore(dfPercentiles[MID8],xMID8)
pct9MID = stats.percentileofscore(dfPercentiles[MID9],xMID9)
pct10MID = stats.percentileofscore(dfPercentiles[MID10],xMID10)
pct11MID = stats.percentileofscore(dfPercentiles[MID11],xMID11)
pct12MID = stats.percentileofscore(dfPercentiles[MID12],xMID12)
pct13MID = stats.percentileofscore(dfPercentiles[MID13],xMID13)
pct14MID = stats.percentileofscore(dfPercentiles[MID14],xMID14)
pct15MID = stats.percentileofscore(dfPercentiles[MID15],xMID15)
pct16MID = stats.percentileofscore(dfPercentiles[MID16],xMID16)
pct17MID = stats.percentileofscore(dfPercentiles[MID17],xMID17)
pct18MID = stats.percentileofscore(dfPercentiles[MID18],xMID18)
pct19MID = stats.percentileofscore(dfPercentiles[MID19],xMID19)
pct20MID = stats.percentileofscore(dfPercentiles[MID20],xMID20)
pct21MID = stats.percentileofscore(dfPercentiles[MID21],xMID21)
pct22MID = stats.percentileofscore(dfPercentiles[MID22],xMID22)
pct23MID = stats.percentileofscore(dfPercentiles[MID23],xMID23)
pct24MID = stats.percentileofscore(dfPercentiles[MID24],xMID24)
pct25MID = stats.percentileofscore(dfPercentiles[MID25],xMID25)
pct26MID = stats.percentileofscore(dfPercentiles[MID26],xMID26)
pct27MID = stats.percentileofscore(dfPercentiles[MID27],xMID27)
pct28MID = stats.percentileofscore(dfPercentiles[MID28],xMID28)
pct1AMW = stats.percentileofscore(dfPercentiles[AMW1],xAMW1)
pct2AMW = stats.percentileofscore(dfPercentiles[AMW2],xAMW2)
pct3AMW = stats.percentileofscore(dfPercentiles[AMW3],xAMW3)
pct4AMW = stats.percentileofscore(dfPercentiles[AMW4],xAMW4)
pct5AMW = stats.percentileofscore(dfPercentiles[AMW5],xAMW5)
pct6AMW = stats.percentileofscore(dfPercentiles[AMW6],xAMW6)
pct7AMW = stats.percentileofscore(dfPercentiles[AMW7],xAMW7)
pct8AMW = stats.percentileofscore(dfPercentiles[AMW8],xAMW8)
pct9AMW = stats.percentileofscore(dfPercentiles[AMW9],xAMW9)
pct10AMW = stats.percentileofscore(dfPercentiles[AMW10],xAMW10)