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

熱線電話:13121318867

登錄
首頁大數(shù)據(jù)時代快速掌握數(shù)據(jù)分析必備工具,ipython和jupyter notebook
快速掌握數(shù)據(jù)分析必備工具,ipython和jupyter notebook
2021-03-11
收藏

來源:麥?zhǔn)寰幊?

作者:麥?zhǔn)?

快速掌握數(shù)據(jù)分析必備工具-i<a href='/map/python/' style='color:#000;font-size:inherit;'>python</a>

本文幫你快速掌握數(shù)據(jù)分析師必須會用的兩個工具 - ipython和jupyter notebook。

既然有了Python,為什么還要ipython?麥?zhǔn)宀挥谜f話,給你一張圖你就明白啦。jupyter notebook又是什么鬼?

建議把本文放到收藏夾。吃灰也好過需要的時候找不到。

一、iPython

iPython是Interactive Python,它是基于Python的一個包裝。它其實就是一個可以通過pip安裝的包。提供了普通python之外的一些功能,其中一個功能就是可以顯示圖片。

快速掌握數(shù)據(jù)分析必備工具-i<a href='/map/python/' style='color:#000;font-size:inherit;'>python</a>

iPython在數(shù)據(jù)分析師,數(shù)據(jù)科學(xué)家,人工智能科學(xué)中經(jīng)常使用。

(1)安裝

python -m pip install ipython

(2)使用

ipython就是Python,使用方法和使用普通的交互式Python一樣,代碼也一樣。只不過輸出顯示上有一定優(yōu)化。

  1. 進入ipython
zjueman@maishu data_analysis % ipython Python 3.8.1 (v3.8.1:1b293b6006, Dec 18 2019, 
14:08:53)  Type 'copyright', 'credits' or 'license' for more information IPython 
7.21.0 -- An enhanced Interactive Python. Type '?' for help. In [1]: 

2.使用ipython:為了運行一下代碼,請先安裝numpy:

python -m pip install numpy
In [1]: a = 5 In [2]: b = "麥?zhǔn)? In [3]: import numpy as np In [4]: 
data = {i:np.random.randn() for i in range(7)} In [5]: data Out[5]:  {0: 0.8738401705018338,  
1: 0.7173530856483666,  2: 1.269301701227684,  3: -0.6322949353286054,  4: -2.3619895093818295,  
5: -0.9031446928993554,  6: -0.07942775508126601}

3.問號尋求幫助:

In [4]: name = 'maishu' In [5]: name?
Type:        str
String form: maishu
Length:      6 Docstring:  
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or
errors is specified, then the object must expose a data buffer
that will be decoded using the given encoding and error handler.
Otherwise, returns the result of object.__str__() (if defined)
or repr(object).
encoding defaults to sys.getdefaultencoding().
errors defaults to 'strict'.

4.退出

In [10]quit() zjueman@maishu data_analysis % 

5.畫圖 為了運行一下代碼需要先安裝matplotlib

python -m pip install matplotlib
In [1]import numpy as np In [2]: %matplotlib Using matplotlib backendMacOSX In [3]import matplotlib.pyplot as plt In [4]plt.plot(np.random.randn(50).cumsum()) Out[4][<matplotlib.lines.line2d?at?0x7fa7e7f8ce20>]matplotlib.lines.line2d?at?0x7fa7e7f8ce20>
快速掌握數(shù)據(jù)分析必備工具-i<a href='/map/python/' style='color:#000;font-size:inherit;'>python</a>

二、jupyter notebook

數(shù)據(jù)科學(xué)家們覺得ipython還不夠過癮,又在ipython基礎(chǔ)上開發(fā)了jupyter notebook:一個基于網(wǎng)頁的寫代碼界面。

快速掌握數(shù)據(jù)分析必備工具-i<a href='/map/python/' style='color:#000;font-size:inherit;'>python</a>

jupyter是基于ipython的,很多操作幾乎都一樣。但是它有很多獨特優(yōu)點:

(1)文件可以保存為ipynb的文件

(2)在線編寫代碼

(3)支持多人協(xié)作

(4)支持markdown格式的文檔

1. 安裝

python -m pip install jupyter

2. 啟動

> jupyter notebook

這個命令會在本機的8888端口上運行一個網(wǎng)站,并自動打開瀏覽器:
http://localhost:8888/tree

快速掌握數(shù)據(jù)分析必備工具-i<a href='/map/python/' style='color:#000;font-size:inherit;'>python</a>

3. 基本使用

(1)創(chuàng)建文件

快速掌握數(shù)據(jù)分析必備工具-i<a href='/map/python/' style='color:#000;font-size:inherit;'>python</a>

(2)編寫和運行代碼

快速掌握數(shù)據(jù)分析必備工具-i<a href='/map/python/' style='color:#000;font-size:inherit;'>python</a>

(3)保存和修改文件名

快速掌握數(shù)據(jù)分析必備工具-i<a href='/map/python/' style='color:#000;font-size:inherit;'>python</a>
  • 文件保存在你打開jupyter notebook的目錄下:
  • 文件的格式是ipynb
快速掌握數(shù)據(jù)分析必備工具-i<a href='/map/python/' style='color:#000;font-size:inherit;'>python</a>

4. Tab補全

在notebook中打代碼的過程中,按Tab鍵可以自動提示和補全,類似于Pycharm和VSCode等IDE的功能:

快速掌握數(shù)據(jù)分析必備工具-i<a href='/map/python/' style='color:#000;font-size:inherit;'>python</a>

它可支持:

(1)自動補全變量名

(2)自動補全函數(shù)名

(3)自動補全文件名等

5. 集成matplotlib畫圖

快速掌握數(shù)據(jù)分析必備工具-i<a href='/map/python/' style='color:#000;font-size:inherit;'>python</a>

6. 魔術(shù)命令

(1)運行腳本:%run

(2)打印命令輸入歷史:%hist

(3)運行效率:%timeit

(4)其他魔術(shù)命令

快速掌握數(shù)據(jù)分析必備工具-i<a href='/map/python/' style='color:#000;font-size:inherit;'>python</a>

7. 快捷鍵

(1)停止執(zhí)行:Ctrl+C

(2)其他ipython快捷鍵

快速掌握數(shù)據(jù)分析必備工具-i<a href='/map/python/' style='color:#000;font-size:inherit;'>python</a>

數(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(), // 加隨機數(shù)防止緩存 type: "get", dataType: "json", success: function (data) { $('#text').hide(); $('#wait').show(); // 調(diào)用 initGeetest 進行初始化 // 參數(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ù)器是否宕機 new_captcha: data.new_captcha, // 用于宕機時表示是新驗證碼的宕機 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); }