This repository contains a comprehensive Eurojackpot lottery analysis and prediction system including: - Historical data analysis and processing - ML-based prediction models - Automated weekly tip generation - Position and range analysis tools - Notification system for results 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
211 lines
7.6 KiB
Python
211 lines
7.6 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Eurojackpot Zahlen-Umschlüsselung
|
|
|
|
Fügt neue Spalten z1, z2, z3, z4, z5 hinzu mit umschlüsselten Werten:
|
|
1-5 → 1, 6-10 → 2, 11-15 → 3, 16-20 → 4, 21-25 → 5,
|
|
26-30 → 6, 31-35 → 7, 36-40 → 8, 41-45 → 9, 46-50 → 10
|
|
"""
|
|
|
|
import pandas as pd
|
|
|
|
def convert_number_to_group(number):
|
|
"""Konvertiert eine Zahl (1-50) in eine Gruppe (1-10)."""
|
|
if 1 <= number <= 5:
|
|
return 1
|
|
elif 6 <= number <= 10:
|
|
return 2
|
|
elif 11 <= number <= 15:
|
|
return 3
|
|
elif 16 <= number <= 20:
|
|
return 4
|
|
elif 21 <= number <= 25:
|
|
return 5
|
|
elif 26 <= number <= 30:
|
|
return 6
|
|
elif 31 <= number <= 35:
|
|
return 7
|
|
elif 36 <= number <= 40:
|
|
return 8
|
|
elif 41 <= number <= 45:
|
|
return 9
|
|
elif 46 <= number <= 50:
|
|
return 10
|
|
else:
|
|
return 0 # Fehlerfall
|
|
|
|
def process_number_conversion():
|
|
"""Führt die Zahlenumschlüsselung durch."""
|
|
|
|
# Eingabedatei laden
|
|
input_file = "/Users/sebastianfrohlich/Library/Mobile Documents/com~apple~CloudDocs/Jupyter Notebooks/Eurojackpot/data/AlleEurojackpotzahlen.csv"
|
|
|
|
print("🔢 EUROJACKPOT ZAHLEN-UMSCHLÜSSELUNG")
|
|
print("="*50)
|
|
|
|
# Daten laden
|
|
print(f"📁 Lade Daten aus: AlleEurojackpotzahlen.csv")
|
|
df = pd.read_csv(input_file, sep=';')
|
|
print(f"✅ {len(df)} Ziehungen geladen")
|
|
|
|
# Umschlüsselungsschema anzeigen
|
|
print(f"\n📋 UMSCHLÜSSELUNGSSCHEMA:")
|
|
print("="*30)
|
|
ranges = [
|
|
(1, 5, 1), (6, 10, 2), (11, 15, 3), (16, 20, 4), (21, 25, 5),
|
|
(26, 30, 6), (31, 35, 7), (36, 40, 8), (41, 45, 9), (46, 50, 10)
|
|
]
|
|
|
|
for start, end, group in ranges:
|
|
print(f"Zahlen {start:2}-{end:2} → Gruppe {group:2}")
|
|
|
|
# Neue Spalten erstellen
|
|
print(f"\n🔄 Erstelle neue Spalten z1, z2, z3, z4, z5...")
|
|
|
|
source_columns = ['Z1', 'Z2', 'Z3', 'Z4', 'Z5']
|
|
target_columns = ['z1', 'z2', 'z3', 'z4', 'z5']
|
|
|
|
for source_col, target_col in zip(source_columns, target_columns):
|
|
df[target_col] = df[source_col].apply(convert_number_to_group)
|
|
print(f" {source_col} → {target_col} ✅")
|
|
|
|
# Erste 5 Beispiele anzeigen
|
|
print(f"\n📊 BEISPIEL-UMSCHLÜSSELUNGEN (erste 5 Ziehungen):")
|
|
print("="*60)
|
|
print(f"{'Datum':<12} {'Z1→z1':<8} {'Z2→z2':<8} {'Z3→z3':<8} {'Z4→z4':<8} {'Z5→z5':<8}")
|
|
print("-" * 60)
|
|
|
|
for i in range(min(5, len(df))):
|
|
row = df.iloc[i]
|
|
datum = row['datum']
|
|
conversions = []
|
|
for source_col, target_col in zip(source_columns, target_columns):
|
|
original = row[source_col]
|
|
converted = row[target_col]
|
|
conversions.append(f"{original:2}→{converted}")
|
|
|
|
print(f"{datum:<12} {conversions[0]:<8} {conversions[1]:<8} {conversions[2]:<8} {conversions[3]:<8} {conversions[4]:<8}")
|
|
|
|
# Statistiken der Umschlüsselung
|
|
print(f"\n📈 STATISTIKEN DER UMSCHLÜSSELTEN WERTE:")
|
|
print("="*45)
|
|
|
|
# Häufigkeit der Gruppen über alle Positionen
|
|
all_converted_values = []
|
|
for target_col in target_columns:
|
|
all_converted_values.extend(df[target_col].tolist())
|
|
|
|
from collections import Counter
|
|
group_counts = Counter(all_converted_values)
|
|
|
|
print(f"Verteilung der Gruppen (1-10) über alle Positionen:")
|
|
total_values = len(all_converted_values)
|
|
|
|
for group in range(1, 11):
|
|
count = group_counts.get(group, 0)
|
|
percentage = (count / total_values) * 100
|
|
original_range = f"{(group-1)*5 + 1}-{group*5}"
|
|
print(f"Gruppe {group:2} ({original_range:5}): {count:4}x ({percentage:5.1f}%)")
|
|
|
|
# Statistiken pro Position
|
|
print(f"\n📊 VERTEILUNG PRO POSITION:")
|
|
print("="*35)
|
|
|
|
for i, target_col in enumerate(target_columns, 1):
|
|
position_counts = Counter(df[target_col])
|
|
print(f"\nPosition z{i} ({target_col}):")
|
|
for group in range(1, 11):
|
|
count = position_counts.get(group, 0)
|
|
percentage = (count / len(df)) * 100
|
|
print(f" Gruppe {group:2}: {count:3}x ({percentage:4.1f}%)")
|
|
|
|
# Häufigste Kombinationen der umschlüsselten Werte
|
|
print(f"\n🎯 HÄUFIGSTE KOMBINATIONEN (umschlüsselt):")
|
|
print("="*45)
|
|
|
|
# Kombinationen als Strings erstellen
|
|
df['kombination_umschluesselt'] = df.apply(
|
|
lambda row: f"{row['z1']}-{row['z2']}-{row['z3']}-{row['z4']}-{row['z5']}", axis=1
|
|
)
|
|
|
|
combination_counts = Counter(df['kombination_umschluesselt'])
|
|
|
|
print(f"Top 15 Kombinationen (z1-z2-z3-z4-z5):")
|
|
for i, (combination, count) in enumerate(combination_counts.most_common(15), 1):
|
|
percentage = (count / len(df)) * 100
|
|
print(f"{i:2}. {combination:15} {count:3}x ({percentage:4.1f}%)")
|
|
|
|
# Muster-Analyse
|
|
print(f"\n🔍 MUSTER-ANALYSE:")
|
|
print("="*25)
|
|
|
|
# Aufsteigende Kombinationen
|
|
ascending_count = 0
|
|
descending_count = 0
|
|
|
|
for _, row in df.iterrows():
|
|
values = [row[col] for col in target_columns]
|
|
if values == sorted(values):
|
|
ascending_count += 1
|
|
elif values == sorted(values, reverse=True):
|
|
descending_count += 1
|
|
|
|
print(f"Aufsteigende Kombinationen: {ascending_count} ({(ascending_count/len(df)*100):.1f}%)")
|
|
print(f"Absteigende Kombinationen: {descending_count} ({(descending_count/len(df)*100):.1f}%)")
|
|
|
|
# Gleiche Werte
|
|
same_values_stats = {}
|
|
for num_same in range(2, 6):
|
|
count = 0
|
|
for _, row in df.iterrows():
|
|
values = [row[col] for col in target_columns]
|
|
value_counts = Counter(values)
|
|
if max(value_counts.values()) >= num_same:
|
|
count += 1
|
|
same_values_stats[num_same] = count
|
|
print(f"Mindestens {num_same} gleiche Werte: {count} ({(count/len(df)*100):.1f}%)")
|
|
|
|
# Bereiche der umschlüsselten Werte
|
|
print(f"\n📋 BEREICHSANALYSE (umschlüsselt):")
|
|
print("="*35)
|
|
|
|
# Niedrig (1-3), Mittel (4-7), Hoch (8-10)
|
|
for i, target_col in enumerate(target_columns, 1):
|
|
low_count = sum(1 for val in df[target_col] if 1 <= val <= 3)
|
|
mid_count = sum(1 for val in df[target_col] if 4 <= val <= 7)
|
|
high_count = sum(1 for val in df[target_col] if 8 <= val <= 10)
|
|
|
|
low_pct = (low_count / len(df)) * 100
|
|
mid_pct = (mid_count / len(df)) * 100
|
|
high_pct = (high_count / len(df)) * 100
|
|
|
|
print(f"z{i}: Niedrig(1-3)={low_pct:4.1f}% | Mittel(4-7)={mid_pct:4.1f}% | Hoch(8-10)={high_pct:4.1f}%")
|
|
|
|
# Ausgabedatei speichern
|
|
output_file = "/Users/sebastianfrohlich/Library/Mobile Documents/com~apple~CloudDocs/Jupyter Notebooks/Eurojackpot/AlleEurojackpotzahlen_umschluesselt.csv"
|
|
|
|
print(f"\n💾 DATEI SPEICHERN:")
|
|
print("="*25)
|
|
|
|
# Spalten neu ordnen (Original + neue Spalten)
|
|
column_order = ['tag', 'datum', 'Z1', 'Z2', 'Z3', 'Z4', 'Z5', 'z1', 'z2', 'z3', 'z4', 'z5', 'SZ1', 'SZ2', 'kombination_umschluesselt']
|
|
|
|
# Prüfen welche Spalten existieren
|
|
available_columns = [col for col in column_order if col in df.columns]
|
|
df_output = df[available_columns]
|
|
|
|
df_output.to_csv(output_file, sep=';', index=False)
|
|
print(f"✅ Umschlüsselte Daten gespeichert: AlleEurojackpotzahlen_umschluesselt.csv")
|
|
print(f"📊 Anzahl Spalten: {len(df_output.columns)}")
|
|
print(f"📈 Anzahl Zeilen: {len(df_output)}")
|
|
|
|
print(f"\n🔍 NEUE SPALTEN:")
|
|
for col in ['z1', 'z2', 'z3', 'z4', 'z5', 'kombination_umschluesselt']:
|
|
if col in df_output.columns:
|
|
print(f" ✅ {col}")
|
|
|
|
return df_output
|
|
|
|
if __name__ == "__main__":
|
|
result_df = process_number_conversion()
|