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

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

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

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

這里接著上一篇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
...

一、藍(lán)球統(tǒng)計(jì):

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)換為對(duì)應(yīng)的數(shù)值從1開始
# print s
tblue = list(reversed(df.loc[:,7]))  #對(duì)數(shù)據(jù)取反
print tblue
fenzu = pd.value_counts(tblue,ascending=False)  #將數(shù)據(jù)進(jìn)行分組統(tǒng)計(jì),按照統(tǒng)計(jì)數(shù)降序排序
print fenzu
x=list(fenzu.index[:])  #獲取藍(lán)色號(hào)碼
y=list(fenzu.values[:])  #獲得藍(lán)色統(tǒng)計(jì)數(shù)量
print x
print y
# print type(fenzu)
plt.figure(figsize=(10,6),dpi=70)  #配置畫圖大小、和細(xì)度
plt.legend(loc='best')
# plt.plot(fenzu,color='red')  #線圖
plt.bar(x,y,alpha=.5, color='b',width=0.8)  #直方圖參數(shù)設(shè)置
plt.title('The blue ball number')  #標(biāo)題
plt.xlabel('blue number')  #x軸內(nèi)容
plt.ylabel('times')  #y軸內(nèi)容
plt.show()  #顯示圖

結(jié)果輸出:

看來(lái)藍(lán)球9選中最多

二、紅球統(tǒng)計(jì)

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選中幾率高些

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

希望本文所述對(duì)大家Python程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論

镇雄县| 兰州市| 海原县| 洪江市| 石泉县| 报价| 策勒县| 西宁市| 久治县| 泾川县| 报价| 宜阳县| 玉环县| 固始县| 乌兰浩特市| 宁德市| 赤水市| 遵化市| 鸡西市| 庆云县| 凤庆县| 体育| 顺义区| 康乐县| 仁化县| 辽阳县| 吉林市| 攀枝花市| 凤翔县| 昆山市| 彩票| 拉萨市| 观塘区| 平顶山市| 湟中县| 靖安县| 泗阳县| 中超| 古蔺县| 泰兴市| 吴桥县|