99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
首頁精彩閱讀基于python二維數(shù)組及畫圖的實例詳解
基于python二維數(shù)組及畫圖的實例詳解
2018-08-15
收藏

基于python二維數(shù)組及畫圖的實例詳解

下面小編就為大家分享一篇基于python 二維數(shù)組及畫圖的實例詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

1、二維數(shù)組取值
注:不管是二維數(shù)組,還是一維數(shù)組,數(shù)組里的數(shù)據(jù)類型要一模一樣,即若是數(shù)值型,全為數(shù)值型    
#二維數(shù)組
import numpy as np
 
list1=[[1.73,1.68,1.71,1.89,1.78],
   [54.4,59.2,63.6,88.4,68.7]]
list3=[1.73,1.68,1.71,1.89,1.78]
list4=[54.4,59.2,63.6,88.4,68.7]
list5=np.array([1.73,1.68,1.71,1.89,1.78])
list6=np.array([54.4,59.2,63.6,88.4,68.7])
#構(gòu)造二維數(shù)組
list=np.array([[1.73,1.68,1.71,1.89,1.78],
   [54.4,59.2,63.6,88.4,68.7]])
print type(list1)
#兩個list直接相運(yùn)算是會報錯的,如果想得到list3中的每個數(shù)據(jù)除以list4中相對應(yīng)的數(shù)據(jù)值,則要引入nump中的array函數(shù)
# print list3/list4
#下面的可以實現(xiàn)list5/list6
print list5/list6
print type(list) #結(jié)果:<type 'numpy.ndarray'>
print list.shape #結(jié)果:(2, 5) 二行5列二維數(shù)組
print list[0][2] #結(jié)果:1.71 ,取第0行第二列數(shù)值,即第三列1.71
print list[0,2]  #結(jié)果:1.71 ,取第0行第二列數(shù)值,即第三列1.71
print list[:,1:3] #結(jié)果:[[ 1.68  1.71] [ 59.2  63.6 ]],取所有行的,第一列和第三列數(shù)據(jù)
print list[1,:]  #結(jié)果:[ 54.4 59.2 63.6 88.4 68.7],取第一行的所有數(shù)值

2、 畫圖

(1)線圖    
import matplotlib.pyplot as plt
year=[1950,1970,1990,2010]
pop=[2.518,3.68,5.23,6.97]
# 1.線圖
#調(diào)用plt。plot來畫圖,橫軸縱軸兩個參數(shù)即可
plt.plot(year,pop)
# python要用show展現(xiàn)出來圖
plt.show()

(2)散點(diǎn)圖    
import matplotlib.pyplot as plt
year=[1950,1970,1990,2010]
pop=[2.518,3.68,5.23,6.97]
#2.散點(diǎn)圖,只是用用scat函數(shù)來調(diào)用即可
plt.scatter(year,pop)
plt.show()

(3)直方圖    
import matplotlib.pyplot as plt
#3.直方圖
# 用hist(x,bins=10)函數(shù)來畫,參數(shù)中x是個List,構(gòu)建直方圖的數(shù)集,bins是算出數(shù)據(jù)的邊界及每個bin中有多少個數(shù)據(jù)點(diǎn)
values=[0,0.6,1.4,1.6,2.2,2.5,2.6,3.2,3.5,3.9,4.2,6]
#有12個數(shù)據(jù),bins=3將其分為3段,即(0,2),(2,4),(4,6),從直方圖中可以看出(2,4)中的數(shù)據(jù)最多
plt.hist(values,bins=3)
plt.show()
以上這篇基于python 二維數(shù)組及畫圖的實例詳解就是小編分享給大家的全部內(nèi)容了

數(shù)據(jù)分析咨詢請掃描二維碼

若不方便掃碼,搜微信號:CDAshujufenxi

數(shù)據(jù)分析師資訊
更多

OK
客服在線
立即咨詢
客服在線
立即咨詢
') } function initGt() { var handler = function (captchaObj) { captchaObj.appendTo('#captcha'); captchaObj.onReady(function () { $("#wait").hide(); }).onSuccess(function(){ $('.getcheckcode').removeClass('dis'); $('.getcheckcode').trigger('click'); }); window.captchaObj = captchaObj; }; $('#captcha').show(); $.ajax({ url: "/login/gtstart?t=" + (new Date()).getTime(), // 加隨機(jī)數(shù)防止緩存 type: "get", dataType: "json", success: function (data) { $('#text').hide(); $('#wait').show(); // 調(diào)用 initGeetest 進(jìn)行初始化 // 參數(shù)1:配置參數(shù) // 參數(shù)2:回調(diào),回調(diào)的第一個參數(shù)驗證碼對象,之后可以使用它調(diào)用相應(yīng)的接口 initGeetest({ // 以下 4 個配置參數(shù)為必須,不能缺少 gt: data.gt, challenge: data.challenge, offline: !data.success, // 表示用戶后臺檢測極驗服務(wù)器是否宕機(jī) new_captcha: data.new_captcha, // 用于宕機(jī)時表示是新驗證碼的宕機(jī) product: "float", // 產(chǎn)品形式,包括:float,popup width: "280px", https: true // 更多配置參數(shù)說明請參見:http://docs.geetest.com/install/client/web-front/ }, handler); } }); } function codeCutdown() { if(_wait == 0){ //倒計時完成 $(".getcheckcode").removeClass('dis').html("重新獲取"); }else{ $(".getcheckcode").addClass('dis').html("重新獲取("+_wait+"s)"); _wait--; setTimeout(function () { codeCutdown(); },1000); } } function inputValidate(ele,telInput) { var oInput = ele; var inputVal = oInput.val(); var oType = ele.attr('data-type'); var oEtag = $('#etag').val(); var oErr = oInput.closest('.form_box').next('.err_txt'); var empTxt = '請輸入'+oInput.attr('placeholder')+'!'; var errTxt = '請輸入正確的'+oInput.attr('placeholder')+'!'; var pattern; if(inputVal==""){ if(!telInput){ errFun(oErr,empTxt); } return false; }else { switch (oType){ case 'login_mobile': pattern = /^1[3456789]\d{9}$/; if(inputVal.length==11) { $.ajax({ url: '/login/checkmobile', type: "post", dataType: "json", data: { mobile: inputVal, etag: oEtag, page_ur: window.location.href, page_referer: document.referrer }, success: function (data) { } }); } break; case 'login_yzm': pattern = /^\d{6}$/; break; } if(oType=='login_mobile'){ } if(!!validateFun(pattern,inputVal)){ errFun(oErr,'') if(telInput){ $('.getcheckcode').removeClass('dis'); } }else { if(!telInput) { errFun(oErr, errTxt); }else { $('.getcheckcode').addClass('dis'); } return false; } } return true; } function errFun(obj,msg) { obj.html(msg); if(msg==''){ $('.login_submit').removeClass('dis'); }else { $('.login_submit').addClass('dis'); } } function validateFun(pat,val) { return pat.test(val); }