import pandas as pd
from collections import Counter
import numpy as np
from io import StringIO # Importa StringIO dal modulo io
Dati storici delle estrazioni
data = “””02/01/2024 01 86 84 52 15 44
04/01/2024 02 49 03 78 79 14
05/01/2024 03 51 58 29 14 22
08/01/2024 04 65 56 10 72 23
09/01/2024 05 74 63 15 28 04
11/01/2024 06 33 81 66 90 56
12/01/2024 07 68 86 14 59 49
13/01/2024 08 88 12 30 23 54
16/01/2024 09 01 45 66 51 48
18/01/2024 10 26 82 58 04 67
19/01/2024 11 53 75 30 46 10
20/01/2024 12 40 42 24 56 50
23/01/2024 13 04 81 32 33 65
25/01/2024 14 76 54 86 74 80
26/01/2024 15 03 35 87 18 28
27/01/2024 16 33 27 02 45 58
30/01/2024 17 18 44 17 48 51
01/02/2024 18 35 48 68 85 39
02/02/2024 19 85 30 77 56 81
03/02/2024 20 34 32 44 66 13
06/02/2024 21 58 85 77 80 73
08/02/2024 22 58 53 30 90 67
09/02/2024 23 90 36 89 75 55
10/02/2024 24 67 24 38 84 13
13/02/2024 25 45 41 89 60 43
15/02/2024 26 41 55 68 65 51
16/02/2024 27 13 06 46 25 31
17/02/2024 28 09 80 01 14 54
20/02/2024 29 44 47 11 34 32
22/02/2024 30 23 28 50 49 51
23/02/2024 31 69 06 88 35 74
24/02/2024 32 27 33 09 46 66
27/02/2024 33 45 83 86 82 51
29/02/2024 34 74 26 33 50 80
01/03/2024 35 43 05 87 74 12
02/03/2024 36 40 71 87 51 56
05/03/2024 37 45 48 62 69 03
07/03/2024 38 56 23 60 41 63
08/03/2024 39 55 32 75 66 27
09/03/2024 40 27 32 70 76 43
12/03/2024 41 23 64 13 81 47
14/03/2024 42 51 85 18 09 73
15/03/2024 43 51 61 54 62 60
16/03/2024 44 13 73 41 43 17
19/03/2024 45 89 85 58 49 08
21/03/2024 46 37 70 86 57 16
22/03/2024 47 25 29 45 51 46
23/03/2024 48 59 81 56 75 58
26/03/2024 49 28 30 54 70 88
28/03/2024 50 66 27 44 90 17
29/03/2024 51 19 51 13 37 08
30/03/2024 52 04 03 18 08 22
02/04/2024 53 58 82 16 61 25
04/04/2024 54 38 26 40 90 41
05/04/2024 55 60 87 30 31 62
06/04/2024 56 72 50 79 70 35
09/04/2024 57 14 05 53 86 17
11/04/2024 58 19 90 88 25 08
12/04/2024 59 55 77 76 02 90
13/04/2024 60 15 90 28 24 51
16/04/2024 61 58 22 11 86 40
18/04/2024 62 85 90 19 67 78
19/04/2024 63 05 56 68 27 09
20/04/2024 64 38 70 31 33 26
23/04/2024 65 61 22 44 19 26
26/04/2024 66 76 24 78 30 40
27/04/2024 67 88 70 85 38 50
29/04/2024 68 76 52 03 22 16
30/04/2024 69 31 56 40 53 50
02/05/2024 70 71 12 04 27 01
03/05/2024 71 60 05 42 75 84
04/05/2024 72 36 30 70 06 41
07/05/2024 73 75 19 18 74 69
09/05/2024 74 16 74 36 55 64
10/05/2024 75 12 33 80 62 75
11/05/2024 76 12 33 75 30 68
14/05/2024 77 09 90 41 32 33
16/05/2024 78 78 09 14 17 85
17/05/2024 79 35 80 90 76 73
18/05/2024 80 84 58 25 64 57
21/05/2024 81 40 80 14 19 13
23/05/2024 82 74 28 44 03 78
24/05/2024 83 28 76 34 11 44
25/05/2024 84 61 46 70 36 65
28/05/2024 85 37 24 82 75 31
30/05/2024 86 31 49 43 18 11
31/05/2024 87 01 24 19 14 63
01/06/2024 88 10 52 67 34 43
04/06/2024 89 84 69 21 57 45
06/06/2024 90 61 20 75 17 02
07/06/2024 91 65 63 41 31 09
08/06/2024 92 77 82 60 10 42
11/06/2024 93 06 01 16 12 20
13/06/2024 94 43 01 79 86 53
14/06/2024 95 20 69 71 19 43
15/06/2024 96 40 61 78 34 54
18/06/2024 97 34 61 32 02 60
20/06/2024 98 63 48 26 84 42
21/06/2024 99 73 41 43 31 17
22/06/2024 100 11 13 15 53 23
25/06/2024 101 23 47 55 60 08
27/06/2024 102 70 28 80 62 18
28/06/2024 103 52 02 38 04 71
29/06/2024 104 46 79 29 14 25
02/07/2024 105 81 37 67 83 64
04/07/2024 106 56 71 51 76 45
05/07/2024 107 65 31 84 86 19
06/07/2024 108 31 78 54 53 52
09/07/2024 109 28 19 84 05 62
11/07/2024 110 73 38 61 26 20
12/07/2024 111 54 07 64 65 63
13/07/2024 112 45 44 76 83 77
16/07/2024 113 10 48 70 07 38
18/07/2024 114 12 67 59 20 48
19/07/2024 115 67 44 30 31 63
20/07/2024 116 69 17 49 75 52
23/07/2024 117 37 09 76 51 61
25/07/2024 118 36 03 30 57 56
26/07/2024 119 14 76 62 50 83
27/07/2024 120 57 10 34 04 02
30/07/2024 121 52 61 29 08 19
01/08/2024 122 35 72 84 33 05
02/08/2024 123 81 28 47 29 20
03/08/2024 124 15 38 41 37 27
06/08/2024 125 83 41 03 11 07
08/08/2024 126 13 35 56 79 75
09/08/2024 127 45 36 89 20 90
10/08/2024 128 39 02 78 36 43
13/08/2024 129 46 37 81 62 18
16/08/2024 130 67 59 84 65 70
17/08/2024 131 75 67 47 53 12
19/08/2024 132 81 59 86 31 04
20/08/2024 133 02 07 31 80 46
22/08/2024 134 85 10 42 29 39
23/08/2024 135 27 71 52 66 21
24/08/2024 136 69 57 01 55 45
27/08/2024 137 09 52 73 43 48
29/08/2024 138 17 03 12 50 63
30/08/2024 139 51 50 10 05 70
31/08/2024 140 46 36 17 49 28
03/09/2024 141 15 14 86 67 09
05/09/2024 142 58 86 08 23 73
06/09/2024 143 08 46 01 32 39
07/09/2024 144 09 31 29 42 55
10/09/2024 145 80 69 07 88 33
12/09/2024 146 59 77 85 37 84
13/09/2024 147 39 35 23 36 81
14/09/2024 148 09 08 51 59 45
17/09/2024 149 34 75 36 29 73
19/09/2024 150 03 14 23 53 06
20/09/2024 151 30 44 68 03 11
21/09/2024 152 11 31 19 67 25
24/09/2024 153 45 53 71 48 38
26/09/2024 154 72 75 01 39 71
27/09/2024 155 09 29 10 43 59
28/09/2024 156 37 01 54 79 15
01/10/2024 157 29 68 31 66 50″””
Creazione di un DataFrame a partire dai dati
df = pd.read_csv(StringIO(data), sep=’\s+’, header=None, names=[‘Date’, ‘Extraction’, ‘N1’, ‘N2’, ‘N3’, ‘N4’, ‘N5’])
Lista di tutti i numeri estratti
all_numbers = []
for col in [‘N1’, ‘N2’, ‘N3’, ‘N4’, ‘N5’]:
all_numbers.extend(df[col].tolist())
Calcolo della frequenza di ogni numero
number_counts = Counter(all_numbers)
Funzione per il punteggio dei ritardatari
def punteggio_ritardatari(numero, df):
last_extraction = df[df.apply(lambda row: numero in row[2:], axis=1)].index.max()
if last_extraction is np.nan:
return 1.0 # numero non presente
else:
return 1 / (len(df) – last_extraction)
Funzione per il punteggio dei numeri frequenti
def punteggio_frequenti(numero, number_counts, total_numbers):
return number_counts[numero] / total_numbers
Calcolo dei punteggi per ogni numero
punteggi = {}
total_numbers = len(all_numbers)
for numero in range(1, 91): # Assumendo che i numeri siano da 1 a 90
punteggi[numero] = (punteggio_ritardatari(numero, df) + punteggio_frequenti(numero, number_counts, total_numbers)) / 2 # media semplice dei punteggi
Ordinamento dei numeri in base ai punteggi
numeri_ordinati = sorted(punteggi, key=punteggi.get, reverse=True)
dieci_numeri_probabili = numeri_ordinati[:10]
print(f”I 10 numeri più probabili sono: {dieci_numeri_probabili}”) cambia le estrazioni storiche con queste e riscrivi il metodo
02/01/2024 01 06 16 43 89 21
04/01/2024 02 50 10 17 81 74
05/01/2024 03 31 59 01 06 62
08/01/2024 04 64 84 49 38 61
09/01/2024 05 40 49 68 85 19
11/01/2024 06 21 89 31 19 15
12/01/2024 07 45 82 39 57 01
13/01/2024 08 85 54 11 36 83
16/01/2024 09 32 19 88 35 16
18/01/2024 10 27 11 85 07 32
19/01/2024 11 25 02 03 75 66
20/01/2024 12 54 42 84 04 37
23/01/2024 13 55 38 29 90 74
25/01/2024 14 02 18 46 22 72
26/01/2024 15 56 85 09 43 58
27/01/2024 16 86 66 57 90 31
30/01/2024 17 55 28 30 40 27
01/02/2024 18 77 53 30 57 61
02/02/2024 19 48 15 60 09 80
03/02/2024 20 15 24 30 83 78
06/02/2024 21 82 52 53 42 54
08/02/2024 22 70 25 56 32 85
09/02/2024 23 18 54 07 64 01
10/02/2024 24 10 51 11 73 86
13/02/2024 25 54 17 52 09 14
15/02/2024 26 05 27 64 87 54
16/02/2024 27 39 23 89 46 77
17/02/2024 28 54 57 61 11 80
20/02/2024 29 73 57 10 05 16
22/02/2024 30 63 76 65 16 88
23/02/2024 31 63 26 02 58 01
24/02/2024 32 14 75 64 31 05
27/02/2024 33 87 14 90 50 68
29/02/2024 34 75 82 27 22 54
01/03/2024 35 90 76 15 20 30
02/03/2024 36 14 53 72 65 75
05/03/2024 37 68 52 38 85 46
07/03/2024 38 47 59 22 40 69
08/03/2024 39 57 14 87 52 89
09/03/2024 40 30 88 37 21 43
12/03/2024 41 79 36 29 05 04
14/03/2024 42 30 48 67 88 71
15/03/2024 43 10 85 32 71 42
16/03/2024 44 06 58 10 37 62
19/03/2024 45 20 41 37 59 72
21/03/2024 46 37 56 20 86 39
22/03/2024 47 02 11 41 56 13
23/03/2024 48 51 16 83 78 59
26/03/2024 49 67 87 22 03 62
28/03/2024 50 09 44 78 85 19
29/03/2024 51 72 67 90 54 20
30/03/2024 52 65 86 81 45 69
02/04/2024 53 86 03 89 49 48
04/04/2024 54 32 07 52 14 86
05/04/2024 55 49 48 24 87 14
06/04/2024 56 75 80 86 09 76
09/04/2024 57 41 47 81 67 70
11/04/2024 58 86 54 18 33 80
12/04/2024 59 75 57 52 26 47
13/04/2024 60 67 14 23 85 90
16/04/2024 61 79 14 36 51 44
18/04/2024 62 60 81 39 33 13
19/04/2024 63 42 50 90 27 83
20/04/2024 64 84 71 65 55 75
23/04/2024 65 21 12 57 82 55
26/04/2024 66 50 56 61 90 57
27/04/2024 67 18 61 70 08 80
29/04/2024 68 39 05 70 26 35
30/04/2024 69 03 19 45 47 25
02/05/2024 70 83 37 42 70 78
03/05/2024 71 17 29 71 48 80
04/05/2024 72 59 23 61 22 27
07/05/2024 73 45 38 26 16 87
09/05/2024 74 77 57 29 34 05
10/05/2024 75 75 10 53 65 71
11/05/2024 76 51 70 74 37 73
14/05/2024 77 66 72 88 81 40
16/05/2024 78 09 17 60 21 46
17/05/2024 79 11 54 27 06 20
18/05/2024 80 53 25 66 59 23
21/05/2024 81 05 82 07 61 47
23/05/2024 82 50 18 03 17 57
24/05/2024 83 26 89 29 61 71
25/05/2024 84 44 77 25 27 26
28/05/2024 85 13 75 60 27 80
30/05/2024 86 52 45 35 49 85
31/05/2024 87 64 15 37 02 44
01/06/2024 88 76 78 57 54 80
04/06/2024 89 30 87 52 55 75
06/06/2024 90 27 18 35 41 03
07/06/2024 91 61 66 86 50 57
08/06/2024 92 34 18 53 30 28
11/06/2024 93 67 02 28 42 62
13/06/2024 94 50 75 68 30 74
14/06/2024 95 75 66 17 58 02
15/06/2024 96 22 80 70 40 69
18/06/2024 97 02 73 61 83 54
20/06/2024 98 80 69 73 77 45
21/06/2024 99 16 06 45 52 75
22/06/2024 100 63 19 10 88 43
25/06/2024 101 72 57 90 74 13
27/06/2024 102 62 51 66 08 53
28/06/2024 103 82 32 64 22 27
29/06/2024 104 32 61 24 70 06
02/07/2024 105 07 15 19 32 39
04/07/2024 106 30 73 04 76 15
05/07/2024 107 42 07 32 68 30
06/07/2024 108 37 58 22 13 79
09/07/2024 109 01 48 54 37 88
11/07/2024 110 60 66 14 03 76
12/07/2024 111 02 60 52 22 54
13/07/2024 112 74 81 09 54 26
16/07/2024 113 69 73 41 44 36
18/07/2024 114 37 78 10 81 73
19/07/2024 115 41 82 68 23 30
20/07/2024 116 76 33 36 66 85
23/07/2024 117 08 34 20 02 72
25/07/2024 118 50 11 55 15 78
26/07/2024 119 89 32 85 53 05
27/07/2024 120 17 08 51 71 76
30/07/2024 121 37 14 44 18 30
01/08/2024 122 09 28 49 21 35
02/08/2024 123 84 13 46 38 62
03/08/2024 124 18 16 52 55 48
06/08/2024 125 40 48 11 03 88
08/08/2024 126 39 65 68 46 13
09/08/2024 127 28 66 11 05 73
10/08/2024 128 83 50 10 22 59
13/08/2024 129 46 76 82 28 04
16/08/2024 130 33 89 01 54 35
17/08/2024 131 37 17 36 66 62
19/08/2024 132 48 17 13 03 54
20/08/2024 133 27 50 64 06 65
22/08/2024 134 82 87 25 22 75
23/08/2024 135 66 74 52 46 13
24/08/2024 136 84 08 72 76 33
27/08/2024 137 70 14 41 43 64
29/08/2024 138 16 17 06 30 55
30/08/2024 139 49 89 27 42 50
31/08/2024 140 53 69 68 01 43
03/09/2024 141 84 61 17 04 26
05/09/2024 142 77 57 65 06 21
06/09/2024 143 48 08 10 04 55
07/09/2024 144 13 59 87 77 34
10/09/2024 145 69 08 24 65 41
12/09/2024 146 06 46 72 55 27
13/09/2024 147 14 65 32 29 87
14/09/2024 148 13 84 86 29 58
17/09/2024 149 49 77 30 45 16
19/09/2024 150 03 88 83 66 07
20/09/2024 151 44 26 08 27 57
21/09/2024 152 20 80 84 59 45
24/09/2024 153 37 44 63 24 51
26/09/2024 154 90 70 77 56 76
27/09/2024 155 11 15 39 35 58
28/09/2024 156 89 76 83 14 59
01/10/2024 157 35 83 26 60 70
To update the provided Python script with the new historical lottery extraction data, we will follow these steps:
- Replace the Old Data: We will replace the historical extraction data with the new data provided.
- Recreate the DataFrame: After replacing the data, we will create a new DataFrame to hold the updated information.
- Recalculate Frequencies and Scores: We will recalculate the frequency of each number and their respective scores based on the new data.
- Output the Ten Most Probable Numbers: Finally, we will print the ten most probable numbers based on the updated calculations.
Here’s how the modified code will look:
import pandas as pd
from collections import Counter
import numpy as np
from io import StringIO
# New historical extraction data
data = """02/01/2024 01 06 16 43 89 21
04/01/2024 02 50 10 17 81 74
05/01/2024 03 31 59 01 06 62
08/01/2024 04 64 84 49 38 61
09/01/2024 05 40 49 68 85 19
11/01/2024 06 21 89 31 19 15
12/01/2024 07 45 82 39 57 01
13/01/2024 08 85 54 11 36 83
16/01/2024 09 32 19 88 35 16
18/01/2024 10 27 11 85 07 32
19/01/2024 11 25 02 03 75 66
20/01/2024 12 54 42 84 04 37
23/01/2024 13 55 38 29 90 74
25/01/2024 14 02 18 46 22 72
26/01/2024 15 56 85 09 43 58
27/01/2024 16 86 66 57 90 31
30/01/2024 17 55 28 30 40 27
01/02/2024 18 77 53 30 57 61
02/02/2024 19 48 15 60 09 80
03/02/2024 20 15 24 30 83 78
06/02/2024 21 82 52 53 42 54
08/02/2024 22 70 25 56 32 85
09/02/2024 23 18 54 07 64 01
10/02/2024 24 10 51 11 73 86
13/02/2024 25 54 17 52 09 14
15/02/2024 26 05 27 64 87 54
16/02/2024 27 39 23 89 46 77
17/02/2024 28 54 57 61 11 80
20/02/2024 29 73 57 10 05 16
22/02/2024 30 63 76 65 16 88
23/02/2024 31 63 26 02 58 01
24/02/2024 32 14 75 64 31 05
27/02/2024 33 87 14 90 50 68
29/02/2024 34 75 82 27 22 54
01/03/2024 35 90 76 15 20 30
02/03/2024 36 14 53 72 65 75
05/03/2024 37 68 52 38 85 46
07/03/2024 38 47 59 22 40 69
08/03/2024 39 57 14 87 52 89
09/03/2024 40 30 88 37 21 43
12/03/2024 41 79 36 29 05 04
14/03/2024 42 30 48 67 88 71
15/03/2024 43 10 85 32 71 42
16/03/2024 44 06 58 10 37 62
19/03/2024 45 20 41 37 59 72
21/03/2024 46 37 56 20 86 39
22/03/2024 47 02 11 41 56 13
23/03/2024 48 51 16 83 78 59
26/03/2024 49 67 87 22 03 62
28/03/2024 50 09 44 78 85 19
29/03/2024 51 72 67 90 54 20
30/03/2024 52 65 86 81 45 69
02/04/2024 53 86 03 89 49 48
04/04/2024 54 32 07 52 14 86
05/04/2024 55 49 48 24 87 14
06/04/2024 56 75 80 86 09 76
09/04/2024 57 41 47 81 67 70
11/04/2024 58 86 54 18 33 80
12/04/2024 59 75 57 52 26 47
13/04/2024 60 67 14 23 85 90
16/04/2024 61 79 14 36 51 44
18/04/2024 62 60 81 39 33 13
19/04/2024 63 42 50 90 27 83
20/04/2024 64 84 71 65 55 75
23/04/2024 65 21 12 57 82 55
26/04/2024 66 50 56 61 90 57
27/04/2024 67 18 61 70 08 80
29/04/2024 68 39 05 70 26 35
30/04/2024 69 03 19 45 47 25
02/05/2024 70 83 37 42 70 78
03/05/2024 71 17 29 71 48 80
04/05/2024 72 59 23 61 22 27
07/05/2024 73 45 38 26 16 87
09/05/2024 74 77 57 29 34 05
10/05/2024 75 75 10 53 65 71
11/05/2024 76 51 70 74 37 73
14/05/2024 77 66 72 88 81 40
16/05/2024 78 09 17 60 21 46
17/05/2024 79 11 54 27 06 20
18/05/2024 80 53 25 66 59 23
21/05/2024 81 05 82 07 61 47
23/05/2024 82 50 18 03 17 57
24/05/2024 83 26 89 29 61 71
25/05/2024 84 44 77 25 27 26
28/05/2024 85 13 75 60 27 80
30/05/2024 86 52 45 35 49 85
31/05/2024 87 64 15 37 02 44
01/06/2024 88 76 78 57 54 80
04/06/2024 89 30 87 52 55 75
06/06/2024 90 27 18 35 41 03
07/06/2024 91 61 66 86 50 57
08/06/2024 92 34 18 53 30 28
11/06/2024 93 67 02 28 42 62
13/06/2024 94 50 75 68 30 74
14/06/2024 95 75 66 17 58 02
15/06/2024 96 22 80 70 40 69
18/06/2024 97 02 73 61 83 54
20/06/2024 98 80 69 73 77 45
21/06/2024 99 16 06 45 52 75
22/06/2024 100 63 19 10 88 43
25/06/2024 101 72 57 90 74 13
27/06/2024 102 62 51 66 08 53
28/06/2024 103 82 32 64 22 27
29/06/2024 104 32 61 24 70 06
02/07/2024 105 07 15 19 32 39
04/07/2024 106 30 73 04 76 15
05/07/2024 107 42 07 32 68 30
06/07/2024 108 37 58 22 13 79
09/07/2024 109 01 48 54 37 88
11/07/2024 110 60 66 14 03 76
12/07/2024 111 02 60 52 22 54
13/07/2024 112 74 81 09 54 26
16/07/2024 113 69 73 41 44 36
18/07/2024 114 37 78 10 81 73
19/07/2024 115 41 82 68 23 30
20/07/2024 116 76 33 36 66 85
23/07/2024 117 08 34 20 02 72
25/07/2024 118 50 11 55 15 78
26/07/2024 119 89 32 85 53 05
27/07/2024 120 17 08 51 71 76
30/07/2024 121 37 14 44 18 30
01/08/2024 122 09 28 49 21 35
02/08/2024 123 84 13 46 38 62
03/08/2024 124 18 16 52 55 48
06/08/2024 125 40 48 11 03 88
08/08/2024 126 39 65 68 46 13
09/08/2024 127 28 66 11 05 73
10/08/2024 128 83 50 10 22 59
13/08/2024 129 46 76 82 28 04
16/08/2024 130 33 89 01 54 35
17/08/2024 131 37 17 36 66 62
19/08/2024 132 48 17 13 03 54
20/08/2024 133 27 50 64 06 65
22/08/2024 134 82 87 25 22 75
23/08/2024 135 66 74 52 46 13
24/08/2024 136 84 08 72 76 33
27/08/2024 137 70 14 41 43 64
29/08/2024 138 16 17 06 30 55
30/08/2024 139 49 89 27 42 50
31/08/2024 140 53 69 68 01 43
03/09/2024 141 84 61 17 04 26
05/09/2024 142 77 57 65 06 21
06/09/2024 143 48 08 10 04 55
07/09/2024 144 13 59 87 77 34
10/09/2024 145 69 08 24 65 41
12/09/2024 146 06 46 72 55 27
13/09/2024 147 14 65 32 29 87
14/09/2024 148 13 84 86 29 58
17/09/2024 149 49 77 30 45 16
19/09/2024 150 03 88 83 66 07
20/09/2024 151 44 26 08 27 57
21/09/2024 152 20 80 84 59 45
24/09/2024 153 37 44 63 24 51
26/09/2024 154 90 70 77 56 76
27/09/2024 155 11 15 39 35 58
28/09/2024 156 89 76 83 14 59
01/10/2024 157 35 83 26 60 70"""
# Create a DataFrame from the new data
df = pd.read_csv(StringIO(data), sep='\s+', header=None, names=['Date', 'Extraction', 'N1', 'N2', 'N3', 'N4', 'N5'])
# List of all drawn numbers
all_numbers = []
for col in ['N1', 'N2', 'N3', 'N4', 'N5']:
all_numbers.extend(df[col].tolist())
# Calculate the frequency of each number
number_counts = Counter(all_numbers)
# Function to calculate the score for overdue numbers
def punteggio_ritardatari(numero, df):
last_extraction = df[df.apply(lambda row: numero in row[2:], axis=1)].index.max()
if np.isnan(last_extraction):
return 1.0 # Number not present
else:
return 1 / (len(df) - last_extraction)
# Function to calculate the score for frequent numbers
def punteggio_frequenti(numero, number_counts, total_numbers):
return number_counts[numero] / total_numbers
# Calculate scores for each number
punteggi = {}
total_numbers = len(all_numbers)
for numero in range(1, 91): # Assuming numbers are from 1 to 90
punteggi[numero] = (punteggio_ritardatari(numero, df) + punteggio_frequenti(numero, number_counts, total_numbers)) / 2 # Simple average of scores
# Sort numbers based on scores
numeri_ordinati = sorted(punteggi, key=punteggi.get, reverse=True)
dieci_numeri_probabili = numeri_ordinati[:10]
print(f"I 10 numeri più probabili sono: {dieci_numeri_probabili}")
Explanation of Changes:
- The historical data at the beginning of the script has been replaced with the new data provided.
- The rest of the code remains the same, focusing on calculating the frequencies and scores for the numbers based on the newly provided extraction data.
- Finally, the script outputs the ten most probable numbers based on this new data.
When you run this code, it will give you the updated probable numbers based on the new extraction history.
import pandas as pd
from collections import Counter
import numpy as np
from io import StringIO
New historical extraction data
data = “””02/01/2024 01 06 16 43 89 21
04/01/2024 02 50 10 17 81 74
05/01/2024 03 31 59 01 06 62
08/01/2024 04 64 84 49 38 61
09/01/2024 05 40 49 68 85 19
11/01/2024 06 21 89 31 19 15
12/01/2024 07 45 82 39 57 01
13/01/2024 08 85 54 11 36 83
16/01/2024 09 32 19 88 35 16
18/01/2024 10 27 11 85 07 32
19/01/2024 11 25 02 03 75 66
20/01/2024 12 54 42 84 04 37
23/01/2024 13 55 38 29 90 74
25/01/2024 14 02 18 46 22 72
26/01/2024 15 56 85 09 43 58
27/01/2024 16 86 66 57 90 31
30/01/2024 17 55 28 30 40 27
01/02/2024 18 77 53 30 57 61
02/02/2024 19 48 15 60 09 80
03/02/2024 20 15 24 30 83 78
06/02/2024 21 82 52 53 42 54
08/02/2024 22 70 25 56 32 85
09/02/2024 23 18 54 07 64 01
10/02/2024 24 10 51 11 73 86
13/02/2024 25 54 17 52 09 14
15/02/2024 26 05 27 64 87 54
16/02/2024 27 39 23 89 46 77
17/02/2024 28 54 57 61 11 80
20/02/2024 29 73 57 10 05 16
22/02/2024 30 63 76 65 16 88
23/02/2024 31 63 26 02 58 01
24/02/2024 32 14 75 64 31 05
27/02/2024 33 87 14 90 50 68
29/02/2024 34 75 82 27 22 54
01/03/2024 35 90 76 15 20 30
02/03/2024 36 14 53 72 65 75
05/03/2024 37 68 52 38 85 46
07/03/2024 38 47 59 22 40 69
08/03/2024 39 57 14 87 52 89
09/03/2024 40 30 88 37 21 43
12/03/2024 41 79 36 29 05 04
14/03/2024 42 30 48 67 88 71
15/03/2024 43 10 85 32 71 42
16/03/2024 44 06 58 10 37 62
19/03/2024 45 20 41 37 59 72
21/03/2024 46 37 56 20 86 39
22/03/2024 47 02 11 41 56 13
23/03/2024 48 51 16 83 78 59
26/03/2024 49 67 87 22 03 62
28/03/2024 50 09 44 78 85 19
29/03/2024 51 72 67 90 54 20
30/03/2024 52 65 86 81 45 69
02/04/2024 53 86 03 89 49 48
04/04/2024 54 32 07 52 14 86
05/04/2024 55 49 48 24 87 14
06/04/2024 56 75 80 86 09 76
09/04/2024 57 41 47 81 67 70
11/04/2024 58 86 54 18 33 80
12/04/2024 59 75 57 52 26 47
13/04/2024 60 67 14 23 85 90
16/04/2024 61 79 14 36 51 44
18/04/2024 62 60 81 39 33 13
19/04/2024 63 42 50 90 27 83
20/04/2024 64 84 71 65 55 75
23/04/2024 65 21 12 57 82 55
26/04/2024 66 50 56 61 90 57
27/04/2024 67 18 61 70 08 80
29/04/2024 68 39 05 70 26 35
30/04/2024 69 03 19 45 47 25
02/05/2024 70 83 37 42 70 78
03/05/2024 71 17 29 71 48 80
04/05/2024 72 59 23 61 22 27
07/05/2024 73 45 38 26 16 87
09/05/2024 74 77 57 29 34 05
10/05/2024 75 75 10 53 65 71
11/05/2024 76 51 70 74 37 73
14/05/2024 77 66 72 88 81 40
16/05/2024 78 09 17 60 21 46
17/05/2024 79 11 54 27 06 20
18/05/2024 80 53 25 66 59 23
21/05/2024 81 05 82 07 61 47
23/05/2024 82 50 18 03 17 57
24/05/2024 83 26 89 29 61 71
25/05/2024 84 44 77 25 27 26
28/05/2024 85 13 75 60 27 80
30/05/2024 86 52 45 35 49 85
31/05/2024 87 64 15 37 02 44
01/06/2024 88 76 78 57 54 80
04/06/2024 89 30 87 52 55 75
06/06/2024 90 27 18 35 41 03
07/06/2024 91 61 66 86 50 57
08/06/2024 92 34 18 53 30 28
11/06/2024 93 67 02 28 42 62
13/06/2024 94 50 75 68 30 74
14/06/2024 95 75 66 17 58 02
15/06/2024 96 22 80 70 40 69
18/06/2024 97 02 73 61 83 54
20/06/2024 98 80 69 73 77 45
21/06/2024 99 16 06 45 52 75
22/06/2024 100 63 19 10 88 43
25/06/2024 101 72 57 90 74 13
27/06/2024 102 62 51 66 08 53
28/06/2024 103 82 32 64 22 27
29/06/2024 104 32 61 24 70 06
02/07/2024 105 07 15 19 32 39
04/07/2024 106 30 73 04 76 15
05/07/2024 107 42 07 32 68 30
06/07/2024 108 37 58 22 13 79
09/07/2024 109 01 48 54 37 88
11/07/2024 110 60 66 14 03 76
12/07/2024 111 02 60 52 22 54
13/07/2024 112 74 81 09 54 26
16/07/2024 113 69 73 41 44 36
18/07/2024 114 37 78 10 81 73
19/07/2024 115 41 82 68 23 30
20/07/2024 116 76 33 36 66 85
23/07/2024 117 08 34 20 02 72
25/07/2024 118 50 11 55 15 78
26/07/2024 119 89 32 85 53 05
27/07/2024 120 17 08 51 71 76
30/07/2024 121 37 14 44 18 30
01/08/2024 122 09 28 49 21 35
02/08/2024 123 84 13 46 38 62
03/08/2024 124 18 16 52 55 48
06/08/2024 125 40 48 11 03 88
08/08/2024 126 39 65 68 46 13
09/08/2024 127 28 66 11 05 73
10/08/2024 128 83 50 10 22 59
13/08/2024 129 46 76 82 28 04
16/08/2024 130 33 89 01 54 35
17/08/2024 131 37 17 36 66 62
19/08/2024 132 48 17 13 03 54
20/08/2024 133 27 50 64 06 65
22/08/2024 134 82 87 25 22 75
23/08/2024 135 66 74 52 46 13
24/08/2024 136 84 08 72 76 33
27/08/2024 137 70 14 41 43 64
29/08/2024 138 16 17 06 30 55
30/08/2024 139 49 89 27 42 50
31/08/2024 140 53 69 68 01 43
03/09/2024 141 84 61 17 04 26
05/09/2024 142 77 57 65 06 21
06/09/2024 143 48 08 10 04 55
07/09/2024 144 13 59 87 77 34
10/09/2024 145 69 08 24 65 41
12/09/2024 146 06 46 72 55 27
13/09/2024 147 14 65 32 29 87
14/09/2024 148 13 84 86 29 58
17/09/2024 149 49 77 30 45 16
19/09/2024 150 03 88 83 66 07
20/09/2024 151 44 26 08 27 57
21/09/2024 152 20 80 84 59 45
24/09/2024 153 37 44 63 24 51
26/09/2024 154 90 70 77 56 76
27/09/2024 155 11 15 39 35 58
28/09/2024 156 89 76 83 14 59
01/10/2024 157 35 83 26 60 70″””
Create a DataFrame from the new data
df = pd.read_csv(StringIO(data), sep=’\s+’, header=None, names=[‘Date’, ‘Extraction’, ‘N1’, ‘N2’, ‘N3’, ‘N4’, ‘N5’])
List of all drawn numbers
all_numbers = []
for col in [‘N1’, ‘N2’, ‘N3’, ‘N4’, ‘N5’]:
all_numbers.extend(df[col].tolist())
Calculate the frequency of each number
number_counts = Counter(all_numbers)
Function to calculate the score for overdue numbers
def punteggio_ritardatari(numero, df):
last_extraction = df[df.apply(lambda row: numero in row[2:], axis=1)].index.max()
if np.isnan(last_extraction):
return 1.0 # Number not present
else:
return 1 / (len(df) – last_extraction)
Function to calculate the score for frequent numbers
def punteggio_frequenti(numero, number_counts, total_numbers):
return number_counts[numero] / total_numbers
Calculate scores for each number
punteggi = {}
total_numbers = len(all_numbers)
for numero in range(1, 91): # Assuming numbers are from 1 to 90
punteggi[numero] = (punteggio_ritardatari(numero, df) + punteggio_frequenti(numero, number_counts, total_numbers)) / 2 # Simple average of scores
Sort numbers based on scores
numeri_ordinati = sorted(punteggi, key=punteggi.get, reverse=True)
dieci_numeri_probabili = numeri_ordinati[:10]
print(f”I 10 numeri più probabili sono: {dieci_numeri_probabili}”) modifica e riscrivi lo script immettendo queste estrazioni
02/01/2024 01 64 09 06 49 70
04/01/2024 02 79 42 25 86 67
05/01/2024 03 77 02 44 67 16
08/01/2024 04 72 70 61 15 54
09/01/2024 05 44 21 72 31 60
11/01/2024 06 84 15 82 31 28
12/01/2024 07 51 12 61 27 23
13/01/2024 08 46 13 41 88 28
16/01/2024 09 65 36 04 69 87
18/01/2024 10 20 87 37 53 34
19/01/2024 11 03 57 53 28 89
20/01/2024 12 88 61 45 78 38
23/01/2024 13 58 38 65 16 10
25/01/2024 14 41 54 87 24 90
26/01/2024 15 39 87 50 31 82
27/01/2024 16 62 75 68 06 52
30/01/2024 17 70 20 53 71 69
01/02/2024 18 53 35 79 41 37
02/02/2024 19 71 09 50 68 15
03/02/2024 20 73 26 05 78 17
06/02/2024 21 53 86 52 76 40
08/02/2024 22 84 41 59 50 10
09/02/2024 23 30 21 03 44 24
10/02/2024 24 34 46 87 18 86
13/02/2024 25 14 07 82 37 87
15/02/2024 26 25 38 78 10 84
16/02/2024 27 10 19 61 65 40
17/02/2024 28 75 24 73 14 78
20/02/2024 29 80 26 48 61 59
22/02/2024 30 42 34 24 20 08
23/02/2024 31 69 48 49 52 24
24/02/2024 32 73 42 28 69 80
27/02/2024 33 60 64 72 65 82
29/02/2024 34 72 58 60 41 33
01/03/2024 35 24 43 16 27 05
02/03/2024 36 12 01 76 05 44
05/03/2024 37 08 04 02 05 74
07/03/2024 38 78 16 69 40 48
08/03/2024 39 33 40 44 29 61
09/03/2024 40 05 55 06 43 10
12/03/2024 41 69 36 09 33 82
14/03/2024 42 47 89 72 27 54
15/03/2024 43 56 48 82 02 63
16/03/2024 44 43 71 21 85 23
19/03/2024 45 33 27 70 15 59
21/03/2024 46 24 34 08 49 58
22/03/2024 47 67 09 51 34 29
23/03/2024 48 75 68 32 70 11
26/03/2024 49 22 34 13 47 24
28/03/2024 50 70 14 47 38 27
29/03/2024 51 75 11 59 90 51
30/03/2024 52 90 49 38 37 05
02/04/2024 53 34 18 67 65 86
04/04/2024 54 10 11 46 16 25
05/04/2024 55 58 73 27 34 84
06/04/2024 56 04 21 88 05 31
09/04/2024 57 69 59 47 26 62
11/04/2024 58 09 06 33 30 05
12/04/2024 59 63 62 48 38 54
13/04/2024 60 67 53 40 90 84
16/04/2024 61 25 27 16 77 79
18/04/2024 62 90 01 83 11 88
19/04/2024 63 16 71 29 85 04
20/04/2024 64 61 32 48 15 24
23/04/2024 65 66 05 11 70 30
26/04/2024 66 87 21 15 12 79
27/04/2024 67 85 81 16 03 26
29/04/2024 68 43 86 23 67 18
30/04/2024 69 71 48 51 12 13
02/05/2024 70 28 72 27 30 07
03/05/2024 71 02 33 81 85 63
04/05/2024 72 05 17 69 57 39
07/05/2024 73 06 23 72 66 05
09/05/2024 74 69 33 28 18 21
10/05/2024 75 80 74 52 08 12
11/05/2024 76 50 81 15 25 71
14/05/2024 77 89 64 72 12 39
16/05/2024 78 30 22 60 06 67
17/05/2024 79 07 72 48 37 15
18/05/2024 80 22 75 48 16 77
21/05/2024 81 86 37 62 02 55
23/05/2024 82 75 01 03 25 12
24/05/2024 83 88 12 13 56 61
25/05/2024 84 14 90 44 34 57
28/05/2024 85 44 35 09 90 67
30/05/2024 86 74 01 45 03 33
31/05/2024 87 80 85 72 36 89
01/06/2024 88 08 01 12 21 39
04/06/2024 89 02 75 64 55 36
06/06/2024 90 50 16 26 66 73
07/06/2024 91 75 27 81 43 63
08/06/2024 92 55 81 33 53 24
11/06/2024 93 51 34 26 25 85
13/06/2024 94 80 63 18 78 84
14/06/2024 95 49 38 39 46 28
15/06/2024 96 47 31 28 72 53
18/06/2024 97 71 15 17 43 73
20/06/2024 98 25 82 39 27 20
21/06/2024 99 58 75 51 29 11
22/06/2024 100 16 14 77 83 88
25/06/2024 101 50 65 21 76 22
27/06/2024 102 05 55 46 51 56
28/06/2024 103 28 85 04 65 13
29/06/2024 104 41 07 09 70 16
02/07/2024 105 90 63 26 64 70
04/07/2024 106 24 80 38 02 52
05/07/2024 107 50 67 64 36 41
06/07/2024 108 88 71 90 77 20
09/07/2024 109 35 32 06 15 63
11/07/2024 110 49 80 14 70 65
12/07/2024 111 62 63 06 61 58
13/07/2024 112 09 19 08 73 34
16/07/2024 113 22 43 11 37 27
18/07/2024 114 33 38 30 02 18
19/07/2024 115 45 68 58 37 73
20/07/2024 116 07 51 80 89 41
23/07/2024 117 06 76 74 73 26
25/07/2024 118 76 70 74 68 80
26/07/2024 119 11 32 21 09 75
27/07/2024 120 73 68 62 47 53
30/07/2024 121 69 88 15 07 06
01/08/2024 122 12 18 34 19 70
02/08/2024 123 85 89 55 43 20
03/08/2024 124 43 16 37 66 28
06/08/2024 125 47 06 20 45 28
08/08/2024 126 59 06 63 79 39
09/08/2024 127 41 65 75 09 33
10/08/2024 128 71 88 28 15 01
13/08/2024 129 44 19 53 02 21
16/08/2024 130 06 27 08 64 51
17/08/2024 131 11 54 43 42 56
19/08/2024 132 66 38 03 52 64
20/08/2024 133 56 54 07 60 41
22/08/2024 134 73 40 90 41 87
23/08/2024 135 07 51 14 01 74
24/08/2024 136 54 84 72 82 88
27/08/2024 137 34 50 06 25 85
29/08/2024 138 21 26 82 40 19
30/08/2024 139 48 22 60 62 71
31/08/2024 140 79 03 19 83 55
03/09/2024 141 73 57 83 23 74
05/09/2024 142 05 11 74 72 37
06/09/2024 143 79 85 63 30 47
07/09/2024 144 26 75 62 77 85
10/09/2024 145 86 30 06 72 82
12/09/2024 146 06 54 21 88 17
13/09/2024 147 42 65 61 39 22
14/09/2024 148 62 27 41 21 76
17/09/2024 149 05 64 60 46 45
19/09/2024 150 60 84 46 90 06
20/09/2024 151 31 64 51 81 47
21/09/2024 152 63 71 19 46 79
24/09/2024 153 58 51 17 13 78
26/09/2024 154 50 63 90 10 72
27/09/2024 155 74 29 46 13 62
28/09/2024 156 87 85 30 76 10
01/10/2024 157 42 90 18 35 82
To modify the provided Python script with the new historical lottery extraction data, we will replace the existing data with the new extraction results. Below is the updated script.
Modified Python Script
import pandas as pd
from collections import Counter
import numpy as np
from io import StringIO
# New historical extraction data
data = """02/01/2024 01 64 09 06 49 70
04/01/2024 02 79 42 25 86 67
05/01/2024 03 77 02 44 67 16
08/01/2024 04 72 70 61 15 54
09/01/2024 05 44 21 72 31 60
11/01/2024 06 84 15 82 31 28
12/01/2024 07 51 12 61 27 23
13/01/2024 08 46 13 41 88 28
16/01/2024 09 65 36 04 69 87
18/01/2024 10 20 87 37 53 34
19/01/2024 11 03 57 53 28 89
20/01/2024 12 88 61 45 78 38
23/01/2024 13 58 38 65 16 10
25/01/2024 14 41 54 87 24 90
26/01/2024 15 39 87 50 31 82
27/01/2024 16 62 75 68 06 52
30/01/2024 17 70 20 53 71 69
01/02/2024 18 53 35 79 41 37
02/02/2024 19 71 09 50 68 15
03/02/2024 20 73 26 05 78 17
06/02/2024 21 53 86 52 76 40
08/02/2024 22 84 41 59 50 10
09/02/2024 23 30 21 03 44 24
10/02/2024 24 34 46 87 18 86
13/02/2024 25 14 07 82 37 87
15/02/2024 26 25 38 78 10 84
16/02/2024 27 10 19 61 65 40
17/02/2024 28 75 24 73 14 78
20/02/2024 29 80 26 48 61 59
22/02/2024 30 42 34 24 20 08
23/02/2024 31 69 48 49 52 24
24/02/2024 32 73 42 28 69 80
27/02/2024 33 60 64 72 65 82
29/02/2024 34 72 58 60 41 33
01/03/2024 35 24 43 16 27 05
02/03/2024 36 12 01 76 05 44
05/03/2024 37 08 04 02 05 74
07/03/2024 38 78 16 69 40 48
08/03/2024 39 33 40 44 29 61
09/03/2024 40 05 55 06 43 10
12/03/2024 41 69 36 09 33 82
14/03/2024 42 47 89 72 27 54
15/03/2024 43 56 48 82 02 63
16/03/2024 44 43 71 21 85 23
19/03/2024 45 33 27 70 15 59
21/03/2024 46 24 34 08 49 58
22/03/2024 47 67 09 51 34 29
23/03/2024 48 75 68 32 70 11
26/03/2024 49 22 34 13 47 24
28/03/2024 50 70 14 47 38 27
29/03/2024 51 75 11 59 90 51
30/03/2024 52 90 49 38 37 05
02/04/2024 53 34 18 67 65 86
04/04/2024 54 10 11 46 16 25
05/04/2024 55 58 73 27 34 84
06/04/2024 56 04 21 88 05 31
09/04/2024 57 69 59 47 26 62
11/04/2024 58 09 06 33 30 05
12/04/2024 59 63 62 48 38 54
13/04/2024 60 67 53 40 90 84
16/04/2024 61 25 27 16 77 79
18/04/2024 62 90 01 83 11 88
19/04/2024 63 16 71 29 85 04
20/04/2024 64 61 32 48 15 24
23/04/2024 65 66 05 11 70 30
26/04/2024 66 87 21 15 12 79
27/04/2024 67 85 81 16 03 26
29/04/2024 68 43 86 23 67 18
30/04/2024 69 71 48 51 12 13
02/05/2024 70 28 72 27 30 07
03/05/2024 71 02 33 81 85 63
04/05/2024 72 05 17 69 57 39
07/05/2024 73 06 23 72 66 05
09/05/2024 74 69 33 28 18 21
10/05/2024 75 80 74 52 08 12
11/05/2024 76 50 81 15 25 71
14/05/2024 77 89 64 72 12 39
16/05/2024 78 30 22 60 06 67
17/05/2024 79 07 72 48 37 15
18/05/2024 80 22 75 48 16 77
21/05/2024 81 86 37 62 02 55
23/05/2024 82 75 01 03 25 12
24/05/2024 83 88 12 13 56 61
25/05/2024 84 14 90 44 34 57
28/05/2024 85 44 35 09 90 67
30/05/2024 86 74 01 45 03 33
31/05/2024 87 80 85 72 36 89
01/06/2024 88 08 01 12 21 39
04/06/2024 89 02 75 64 55 36
06/06/2024 90 50 16 26 66 73
07/06/2024 91 75 27 81 43 63
08/06/2024 92 55 81 33 53 24
11/06/2024 93 51 34 26 25 85
13/06/2024 94 80 63 18 78 84
14/06/2024 95 49 38 39 46 28
15/06/2024 96 47 31 28 72 53
18/06/2024 97 71 15 17 43 73
20/06/2024 98 25 82 39 27 20
21/06/2024 99 58 75 51 29 11
22/06/2024 100 16 14 77 83 88
25/06/2024 101 50 65 21 76 22
27/06/2024 102 05 55 46 51 56
28/06/2024 103 28 85 04 65 13
29/06/2024 104 41 07 09 70 16
02/07/2024 105 90 63 26 64 70
04/07/2024 106 24 80 38 02 52
05/07/2024 107 50 67 64 36 41
06/07/2024 108 88 71 90 77 20
09/07/2024 109 35 32 06 15 63
11/07/2024 110 49 80 14 70 65
12/07/2024 111 62 63 06 61 58
13/07/2024 112 09 19 08 73 34
16/07/2024 113 22 43 11 37 27
18/07/2024 114 33 38 30 02 18
19/07/2024 115 45 68 58 37 73
20/07/2024 116 07 51 80 89 41
23/07/2024 117 06 76 74 73 26
25/07/2024 118 76 70 74 68 80
26/07/2024 119 11 32 21 09 75
27/07/2024 120 73 68 62 47 53
30/07/2024 121 69 88 15 07 06
01/08/2024 122 12 18 34 19 70
02/08/2024 123 85 89 55 43 20
03/08/2024 124 43 16 37 66 28
06/08/2024 125 47 06 20 45 28
08/08/2024 126 59 06 63 79 39
09/08/2024 127 41 65 75 09 33
10/08/2024 128 71 88 28 15 01
13/08/2024 129 44 19 53 02 21
16/08/2024 130 06 27 08 64 51
17/08/2024 131 11 54 43 42 56
19/08/2024 132 66 38 03 52 64
20/08/2024 133 56 54 07 60 41
22/08/2024 134 73 40 90 41 87
23/08/2024 135 07 51 14 01 74
24/08/2024 136 54 84 72 82 88
27/08/2024 137 34 50 06 25 85
29/08/2024 138 21 26 82 40 19
30/08/2024 139 48 22 60 62 71
31/08/2024 140 79 03 19 83 55
03/09/2024 141 73 57 83 23 74
05/09/2024 142 05 11 74 72 37
06/09/2024 143 79 85 63 30 47
07/09/2024 144 26 75 62 77 85
10/09/2024 145 86 30 06 72 82
12/09/2024 146 06 54 21 88 17
13/09/2024 147 42 65 61 39 22
14/09/2024 148 62 27 41 21 76
17/09/2024 149 05 64 60 46 45
19/09/2024 150 60 84 46 90 06
20/09/2024 151 31 64 51 81 47
21/09/2024 152 63 71 19 46 79
24/09/2024 153 58 51 17 13 78
26/09/2024 154 50 63 90 10 72
27/09/2024 155 74 29 46 13 62
28/09/2024 156 87 85 30 76 10
01/10/2024 157 42 90 18 35 82"""
# Create a DataFrame from the new data
df = pd.read_csv(StringIO(data), sep='\s+', header=None, names=['Date', 'Extraction', 'N1', 'N2', 'N3', 'N4', 'N5'])
# List of all drawn numbers
all_numbers = []
for col in ['N1', 'N2', 'N3', 'N4', 'N5']:
all_numbers.extend(df[col].tolist())
# Calculate the frequency of each number
number_counts = Counter(all_numbers)
# Function to calculate the score for overdue numbers
def punteggio_ritardatari(numero, df):
last_extraction = df[df.apply(lambda row: numero in row[2:], axis=1)].index.max()
if np.isnan(last_extraction):
return 1.0 # Number not present
else:
return 1 / (len(df) - last_extraction)
# Function to calculate the score for frequent numbers
def punteggio_frequenti(numero, number_counts, total_numbers):
return number_counts[numero] / total_numbers
# Calculate scores for each number
punteggi = {}
total_numbers = len(all_numbers)
for numero in range(1, 91): # Assuming numbers are from 1 to 90
punteggi[numero] = (punteggio_ritardatari(numero, df) + punteggio_frequenti(numero, number_counts, total_numbers)) / 2 # Simple average of scores
# Sort numbers based on scores
numeri_ordinati = sorted(punteggi, key=punteggi.get, reverse=True)
dieci_numeri_probabili = numeri_ordinati[:10]
print(f"I 10 numeri più probabili sono: {dieci_numeri_probabili}")
Explanation of Changes:
- Data Replacement: The historical extraction data has been replaced with the new data provided.
- Functionality: The rest of the code remains unchanged, ensuring it processes the new data to identify the most probable numbers just like before.
- Output: The script will output the ten most probable numbers based on the latest extraction data.
Running the Script
To see the results, you can run this script in your Python environment. The output will list the ten numbers deemed most probable based on the provided extraction history.
#chats