熱線電話:13121318867

登錄
首頁大數據時代Series是什么?基本使用方法有哪些?
Series是什么?基本使用方法有哪些?
2020-07-16
收藏

Series 是一種類似于一維數組的對象,它由一組數據(各種NumPy數據類型)以及一組與之 相關的數據標簽(即索引)組成。

一、對于Series定義的理解

1.Series像是一個Python的dict類型,因為它的索引與元素是映射關系

2.  Series也像是一個ndarray類型,因為它也可以通過series_name[index]方式訪問

3.  Series是一維的,但能夠存儲不同類型的數據

4.每個Series都有一組索引與數據對應,若不指定則默認為整型索引

5.不顯式指定index

二、Series常用屬性


三、Series常用函數



四、Series基本用法

1.常規查詢:使用索引,或者使用序號

series0 = Series(np.array(range(3)), index = ["first", "second", "third"], dtype=int)

print(series0[1])

print("#" * 30)

print(series0["first"])

2.切片查詢

(1)索引切片,閉區間

(2)序號切片,前閉后開

series0 = Series(np.array(range(3)), index = ["first", "second", "third"], dtype=int)

print(series0["second": "third"])

print("#" * 30)

print(series0[1:2])

second    1

third     2

dtype: int32

##############################

second    1

dtype: int32

3、條件查詢

series0 = Series(np.array(range(3)), index = ["first", "second", "third"], dtype=int)

print(series0[series0 > 0])

second    1

third     2

dtype: int32

4、新增

series0 = Series(np.array(range(3)), index = ["first", "second", "third"], dtype=int)

series0["fourth"] = 3

print(series0)

first     0

second    1

third     2

fourth    3

dtype: int64

5、刪除

只能根據索引進行刪除,無法直接刪除值

series0 = Series(np.array(range(3)), index = ["first", "second", "third"], dtype=int)

series0 = series0.drop("third")

print(series0)

first     0

second    1

dtype: int32

6、修改

series0 = Series(np.array(range(3)), index = ["first", "second", "third"], dtype=int)

series0["first"] = "first-modify"

print(series0)

series0[1] = "second-modify"

print(series0)

first     first-modify

second               1

third                2

dtype: object

first      first-modify

second    second-modify

third                 2

dtype: object

數據分析咨詢請掃描二維碼

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

數據分析師資訊
更多

OK
客服在線
立即咨詢
日韩人妻系列无码专区视频,先锋高清无码,无码免费视欧非,国精产品一区一区三区无码
客服在線
立即咨詢