Series物件的屬性有:1、index屬性,查看Series物件的索引;2、size屬性,查看Series的元素個數;3、values屬性,將Pandas中的資料格式轉換為Numpy中數組的形式;4、dtype屬性;5、name屬性。
Pandas Series物件共同屬性:
查看Series 的相關屬性,可以查看或更改該序列元素的類型以及索引。
In [1]: import pandas as pd In [2]: a=pd.Series([0,1,2,3,4,5])
1)index屬性
index 屬性可以查看 Series 物件的索引,同樣也可以直接賦值變更。我們使用 .loc 和 .iloc 對索引修改,前後做同樣的處理,請體會 loc 和i loc 的區別,程式碼如下。
In [3]: a.index Out[3]: RangeIndex(start=0, stop=6, step=1) In [4]: a.loc[1] Out[4]: 1 In [5]: a.iloc[1] Out[5]: 1
改變了a的索引,這時 loc[1] 取倒數第2個位置的值,而 iloc[1] 仍然是取絕對位置為 1 的值。
In [6]: a.index = [5,4,3,2,1,0] In [7]: a.index Out[7]: Int64Index([5, 4, 3, 2, 1, 0], dtype='int64') In [8]: a.loc[1] Out[8]: 4 In [9]: a.iloc[1] Out[9]: 1
2) size屬性
size 屬性可以用來查看 Series 的元素個數。
In [10]: a.size # 查看数据的个数 Out[10]: 6
3) values屬性
values 屬性可以作為Pandas 和Numpy 中間轉換的橋樑,透過values 屬性可以將Pandas 中的資料格式轉換為Numpy 中數組的形式。
In [11]: a.values # 查看返回值,返回的是一个Numpy中的array类型 Out[11]: array([0, 1, 2, 3, 4, 5], dtype=int64)
4) dtype屬性
dtype 屬性用來查看資料的類型,然後可以透過 astype 方法對資料類型進行變更。 Pandas 支援許多資料類型,我們需要根據不同的使用情境選擇不同的資料類型。
In [12]: a.dtype # 查看数据类型 Out[12]: dtype('int64') In [13]: a=a.astype('float64') In [14]: a.dtype # 查看数据类型
5) name屬性
取得values的name
##6) index.name屬性
取得索引的name 更多程式相關知識,請造訪:程式設計學習! !
以上是Pandas Series物件的常見屬性有哪些?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

Python是解釋型語言,但也包含編譯過程。 1)Python代碼先編譯成字節碼。 2)字節碼由Python虛擬機解釋執行。 3)這種混合機制使Python既靈活又高效,但執行速度不如完全編譯型語言。

UseeAforloopWheniteratingOveraseQuenceOrforAspecificnumberoftimes; useAwhiLeLoopWhenconTinuingUntilAcIntiment.forloopsareIdealForkNownsences,而WhileLeleLeleLeleLeleLoopSituationSituationsItuationsItuationSuationSituationswithUndEtermentersitations。

pythonloopscanleadtoerrorslikeinfiniteloops,modifyingListsDuringteritation,逐個偏置,零indexingissues,andnestedloopineflinefficiencies

forloopsareadvantageousforknowniterations and sequests,供應模擬性和可讀性;而LileLoopSareIdealFordyNamicConcitionSandunknowniterations,提供ControloperRoverTermination.1)forloopsareperfectForeTectForeTerToratingOrtratingRiteratingOrtratingRitterlistlistslists,callings conspass,calplace,cal,ofstrings ofstrings,orstrings,orstrings,orstrings ofcces

pythonisehybridmodeLofCompilation和interpretation:1)thepythoninterpretercompilesourcecececodeintoplatform- interpententbybytecode.2)thepythonvirtualmachine(pvm)thenexecutecutestestestestestesthisbytecode,ballancingEaseofuseEfuseWithPerformance。

pythonisbothinterpretedAndCompiled.1)它的compiledTobyTecodeForportabilityAcrosplatforms.2)bytecodeisthenInterpreted,允許fordingfordforderynamictynamictymictymictymictyandrapiddefupment,儘管Ititmaybeslowerthananeflowerthanancompiledcompiledlanguages。

在您的知識之際,而foroopsareideal insinAdvance中,而WhileLoopSareBetterForsituations則youneedtoloopuntilaconditionismet

ForboopSareSusedwhenthentheneMberofiterationsiskNownInAdvance,而WhileLoopSareSareDestrationsDepportonAcondition.1)ForloopSareIdealForiteratingOverSequencesLikelistSorarrays.2)whileLeleLooleSuitableApeableableableableableableforscenarioscenarioswhereTheLeTheLeTheLeTeLoopContinusunuesuntilaspecificiccificcificCondond


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

WebStorm Mac版
好用的JavaScript開發工具

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

記事本++7.3.1
好用且免費的程式碼編輯器