最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Python數(shù)據(jù)分析之雙色球中藍紅球分析統(tǒng)計示例

 更新時間:2018年02月03日 09:59:35   作者:levy_cui  
這篇文章主要介紹了Python數(shù)據(jù)分析之雙色球中藍紅球分析統(tǒng)計,結(jié)合實例形式較為詳細的分析了Python針對雙色球藍紅球中獎數(shù)據(jù)分析的相關操作技巧,需要的朋友可以參考下

本文實例講述了Python數(shù)據(jù)分析之雙色球中藍紅球分析統(tǒng)計。分享給大家供大家參考,具體如下:

這里接著上一篇Python數(shù)據(jù)分析之獲取雙色球歷史信息收集的數(shù)據(jù)處理下,

newdata.txt數(shù)據(jù)樣子

...
2005-08-21, 05,10,23,27,28,30,15
2005-08-18, 04,05,17,18,26,33,04
2005-08-16, 09,12,18,21,28,29,05
...

一、藍球統(tǒng)計:

analyze_data_lan.py

#!/usr/bin/python
# -*- coding:UTF-8 -*-
#調(diào)用pandas numpy matplotlib包
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#讀取newdata.txt文件
df = pd.read_table('newdata.txt',header=None,sep=',')
# print df
# print df[1:3]  #第2到第3行(索引0開始為第一行,1代表第二行,不包含第四行)
# print df.loc[0:10,:]  #第1行到第9行的全部列
# print df.loc[:,[0,7]] #全部行的第1和第8列
tdate = sorted(df.loc[:,0])   #取第一列數(shù)據(jù)
# print tdate
tdate1 = []  #將tdate數(shù)據(jù)讀取到列表中
for i in tdate:
  tdate1.append(i)
print tdate1
# s = pd.Series(tdate1, index=tdate1)
s = pd.Series(range(1,len(tdate1)+1), index=tdate1)  #將日期轉(zhuǎn)換為對應的數(shù)值從1開始
# print s
tblue = list(reversed(df.loc[:,7]))  #對數(shù)據(jù)取反
print tblue
fenzu = pd.value_counts(tblue,ascending=False)  #將數(shù)據(jù)進行分組統(tǒng)計,按照統(tǒng)計數(shù)降序排序
print fenzu
x=list(fenzu.index[:])  #獲取藍色號碼
y=list(fenzu.values[:])  #獲得藍色統(tǒng)計數(shù)量
print x
print y
# print type(fenzu)
plt.figure(figsize=(10,6),dpi=70)  #配置畫圖大小、和細度
plt.legend(loc='best')
# plt.plot(fenzu,color='red')  #線圖
plt.bar(x,y,alpha=.5, color='b',width=0.8)  #直方圖參數(shù)設置
plt.title('The blue ball number')  #標題
plt.xlabel('blue number')  #x軸內(nèi)容
plt.ylabel('times')  #y軸內(nèi)容
plt.show()  #顯示圖

結(jié)果輸出:

看來藍球9選中最多

二、紅球統(tǒng)計

analyze_data_hong.py

#!/usr/bin/python
# -*- coding:UTF-8 -*-
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#讀取文件
df = pd.read_table('newdata.txt',header=None,sep=',')
# print df
# print df[1:3]
# print df.loc[0:10,:]
# print df.loc[:,1:6]
tdate = sorted(df.loc[:,0])
# print tdate
h1 = df.loc[:,1]
h2 = df.loc[:,2]
h3 = df.loc[:,3]
h4 = df.loc[:,4]
h5 = df.loc[:,5]
h6 = df.loc[:,6]
#將數(shù)據(jù)合并到一起
all = h1.append(h2).append(h3).append(h4).append(h5).append(h6)
alldata = list(all)
print len(alldata)
fenzu = pd.value_counts(all,ascending=False)
print fenzu
x=list(fenzu.index[:])
y=list(fenzu.values[:])
print x
print y
# print type(fenzu)
plt.figure(figsize=(10,6),dpi=70)
plt.legend(loc='best',)
# plt.plot(fenzu,color='red')
plt.bar(x,y,alpha=.5, color='r',width=0.8)
plt.title('The red ball number')
plt.xlabel('red number')
plt.ylabel('times')
plt.show()

結(jié)果輸出:

紅球1、7、14、17、26選中幾率高些

更多關于Python相關內(nèi)容感興趣的讀者可查看本站專題:《Python數(shù)學運算技巧總結(jié)》、《Python字符串操作技巧匯總》、《Python編碼操作技巧總結(jié)》、《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python入門與進階經(jīng)典教程》及《Python文件與目錄操作技巧匯總

希望本文所述對大家Python程序設計有所幫助。

相關文章

最新評論

丰顺县| 颍上县| 陆丰市| 德昌县| 常熟市| 肃北| 黄平县| 江阴市| 西宁市| 茂名市| 临朐县| 金坛市| 大埔县| 营山县| 易门县| 中牟县| 海林市| 昭觉县| 垫江县| 安义县| 邯郸市| 瑞丽市| 洪洞县| 牙克石市| 汤原县| 临海市| 克什克腾旗| 淅川县| 康乐县| 松江区| 嘉黎县| 深州市| 璧山县| 大安市| 金沙县| 历史| 新安县| 开封市| 涟水县| 石门县| 吉木乃县|