欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Pandas數(shù)據(jù)結(jié)構(gòu)中Series屬性詳解

 更新時間:2022年04月24日 09:09:19   作者:李小四是數(shù)據(jù)分析師  
本文主要介紹了Pandas數(shù)據(jù)結(jié)構(gòu)中Series屬性詳解,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

Series屬性

Series屬性列表

屬性說明
Series.index系列的索引(軸標(biāo)簽)
Series.array系列或索引的數(shù)據(jù)
Series.values系列的數(shù)據(jù),返回ndarray
Series.dtype返回基礎(chǔ)數(shù)據(jù)的數(shù)據(jù)類型
Series.shape返回基礎(chǔ)數(shù)據(jù)形狀的元組
Series.nbytes返回基礎(chǔ)數(shù)據(jù)占的字節(jié)數(shù)
Series.ndim基礎(chǔ)數(shù)據(jù)的維數(shù),永遠(yuǎn)是1
Series.size返回基礎(chǔ)數(shù)據(jù)中元素的個數(shù)
Series.T返回轉(zhuǎn)置,永遠(yuǎn)為Series自己
Series.memory_usage([index, deep])返回系列的內(nèi)存使用情況
Series.hasnans如果有任何 NaN,則返回 True
Series.empty指示 Series是否為空
Series.dtypes返回基礎(chǔ)數(shù)據(jù)的數(shù)據(jù)類型
Series.name返回系列的名稱
Series.flags獲取與此 pandas 對象關(guān)聯(lián)的屬性
Series.set_flags(*[,copy,…])返回帶有更新標(biāo)志的新對象

Series屬性詳解

由于Series是一個可以自定義行索引的一維數(shù)據(jù),所以Series的屬性大部分都是ndarray的屬性,在ndarray屬性的基礎(chǔ)上有了新的擴(kuò)展,其中比較重要的是index,values等。詳細(xì)介紹示例如下:(建議看不懂說明的可以直接看示例,示例更容易懂)

>>> import numpy as np
>>> import pandas as pd
# 創(chuàng)建ser01
>>> arr01 = np.arange(10, 16)
>>> ser01 = pd.Series(data=arr01, index=['a','b','c','d','e','f'], dtype='int16', name='class02')
>>> ser01
a    10
b    11
c    12
d    13
e    14
f    15
Name: class02, dtype: int16

屬性:

Series.index

>>> ser01.index # 索引
Index(['a', 'b', 'c', 'd', 'e', 'f'], dtype='object')

Series.array

>>> ser01.array # 數(shù)組
<PandasArray> # 返回的數(shù)據(jù)類型為PandasArray
[10, 11, 12, 13, 14, 15]
Length: 6, dtype: int16

Series.values

>>> ser01.values # 數(shù)據(jù)
array([10, 11, 12, 13, 14, 15], dtype=int16) # 返回值為ndarray

Series.dtype

>>> ser01.dtype # 元素的數(shù)據(jù)類型
dtype('int16')

Series.shape

>>> ser01.shape # 形狀
(6,)

Series.nbytes

>>> ser01.nbytes # 占用多少字節(jié)
12

Series.ndim

>>> ser01.ndim # 維度,維數(shù),軸數(shù),秩
1 # 永遠(yuǎn)是1,Series是一維數(shù)組

Series.T

>>> ser01.T # 轉(zhuǎn)置,是它本身
a    10
b    11
c    12
d    13
e    14
f    15
Name: class02, dtype: int16

Series.memory_usage([index, deep])

>>> ser01.memory_usage() # 內(nèi)存使用量
232

Series.hasnans

>>> ser01.hasnans # 是否有空值
False

Series.empty

>>> ser01.empty # 是否為空
False

Series.dtypes

>>> ser01.dtypes # 元素數(shù)據(jù)類型,同dtype
dtype('int16')

Series.name

>>> ser01.name # ser01的名字
'class02'

Series.flags

>>> ser01.flags # 此 pandas 對象關(guān)聯(lián)的屬性
<Flags(allows_duplicate_labels=True)>

Series.set_flags(*[,copy,…])

>>> ser01.set_flags() # 返回帶有更新標(biāo)志的新對象
a    10
b    11
c    12
d    13
e    14
f    15
Name: class02, dtype: int32

需要掌握屬性的名稱和意義,還有屬性的返回值屬于哪種數(shù)據(jù)類型,是一個什么值。在數(shù)據(jù)分析或者可視化中會使用Series屬性的返回值作為其他函數(shù)的參數(shù)使用,因此必須熟練掌握。

到此這篇關(guān)于Pandas數(shù)據(jù)結(jié)構(gòu)中Series屬性詳解的文章就介紹到這了,更多相關(guān)Pandas Series屬性內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論