【Python】大乐透双色球快乐8通用冷热号码选号代码

泽江东旭侯 2024-11-08 13:16:38

我们通过遗漏值统计出冷号热门号码以后,可以用个冷号加热门号码来组号,本期,我给大家带来的是,Python乐透通用冷热号码组号代码。

Python统计

import numpy as np import pandas as pd from collections import Counter import random # 最近 20 期数据 举例代码为快乐8可选择大乐透双色球前区号码 data = [ [1,2,7,8,15,32,34,37,38,40,42,49,51,54,59,61,67,69,72,73], [9,10,14,27,28,31,36,39,46,47,60,61,63,64,69,70,71,75,78,80], [3,5,7,11,12,20,21,29,32,33,35,43,45,51,56,58,74,77,79,80], [2,10,12,13,14,23,24,29,31,32,35,37,43,44,45,46,61,64,74,75], [1,2,5,16,19,21,25,31,34,37,42,43,51,53,54,58,59,64,73,80], [1,2,3,8,9,11,12,16,18,24,31,36,39,44,56,58,67,70,74,80], [1,7,11,12,23,27,31,37,39,43,45,50,53,54,55,57,65,67,71,75], [2,12,15,26,27,28,30,31,32,36,38,47,52,54,59,62,63,68,71,76], [5,9,10,15,23,27,29,31,38,39,41,47,54,66,70,71,72,75,76,78], [3,12,13,16,21,38,44,46,50,51,54,62,63,68,69,70,74,76,77,78], [2,6,11,16,18,22,39,46,47,52,55,60,61,66,67,70,71,74,77,78], [1,5,12,13,15,17,18,28,29,34,39,44,55,60,62,64,66,67,70,77], [6,9,11,13,14,18,24,28,29,36,38,41,42,49,51,57,66,71,75,78], [2,12,16,17,23,25,26,27,34,45,51,54,56,58,60,64,67,70,72,77], [5,7,14,18,19,23,26,27,36,37,44,46,50,53,56,58,64,66,73,78], [3,9,11,14,15,18,20,21,25,26,28,40,43,50,54,66,72,76,77,78], [3,7,8,12,13,34,40,43,47,50,54,55,58,61,63,64,66,72,74,78], [11,12,16,19,22,26,27,36,40,42,45,46,48,49,55,65,69,72,74,76], [7,16,22,27,28,34,37,38,39,40,45,46,51,57,63,64,65,73,77,80], [3,5,9,13,20,23,28,31,32,36,42,43,44,49,63,66,68,69,75,76], [9,13,14,18,22,28,33,35,41,45,48,49,51,53,58,68,71,73,74,80] ] # 统计所有数字的出现频率 flat_data = [num for sublist in data for num in sublist] # 将二维数据展平 frequency = Counter(flat_data) # 转换为 DataFrame 以便处理 freq_df = pd.DataFrame(frequency.items(), columns=['Number', 'Frequency']) freq_df = freq_df.sort_values(by='Frequency', ascending=False) # 按频率降序排列 # 识别热号和冷号 hot_numbers = freq_df.head(10) # 出现频率最高的前 10 个号码 cold_numbers = freq_df.tail(10) # 出现频率最低的前 10 个号码 # 显示结果 打印冷热各前十的号码print("热号 (出现频率最高的前 10 个号码):") print(hot_numbers) print("\n冷号 (出现频率最低的前 10 个号码):") print(cold_numbers) # 生成建议的选号可修改hot cold后面的数字 def generate_ticket(hot_numbers, cold_numbers, num_hot=5, num_cold=0): # 在热号中随机选择指定数量的号码 selected_hot = random.sample(hot_numbers['Number'].tolist(), num_hot) # 在冷号中随机选择指定数量的号码 selected_cold = random.sample(cold_numbers['Number'].tolist(), num_cold) # 返回排序的选号 return sorted(selected_hot + selected_cold) # 生成十组选号 可修改10为你想要的数字,5为选五,改5为6就是选六或者双色球number_of_tickets = 10 suggested_tickets = [] for _ in range(number_of_tickets): suggested_tickets.append(generate_ticket(hot_numbers, cold_numbers, 5, 0)) # 显示十组冷热交替随机新号码 print("\n十组随机的号码:") for i, ticket in enumerate(suggested_tickets, 1): print(f"第{i}组号码: {ticket}")

代码模拟运行如下

代码运行模拟

正在运行程序...

[1,2,7,8,15,32,34,37,38,40,42,49,51,54,59,61,67,69,72,73],

热号【数据统计到前天】 (出现频率最高的前 10 个号码):

Number Frequency

24 12 10【12出现10次】

13 64 8【64出现8次】

71 66 8

3 27 8

4 28 8

5 31 8

36 74 8

52 54 8

18 78 8

16 71 7

冷号 (出现频率最低的前 10 个号码):

Number Frequency

1 10 3

73 6 2

75 17 2

53 59 2

66 52 2

55 8 2

29 33 2

78 48 2

64 30 1

38 79 1

十组随机的号码:[数据统计到昨天]

第1组号码: [12, 27, 28, 31, 78]

第2组号码: [28, 54, 64, 66, 74]

第3组号码: [28, 31, 51, 74, 78]

第4组号码: [12, 28, 31, 51, 66]

第5组号码: [12, 31, 51, 54, 78]

第6组号码: [12, 28, 51, 54, 66]

第7组号码: [27, 51, 54, 64, 66]

第8组号码: [28, 31, 51, 64, 66]

第9组号码: [28, 31, 64, 74, 78]

第10组号码: [12, 27, 54, 64, 78]

2 阅读:183
评论列表
  • 2024-11-08 19:34

    可以分享一下吗