網站首頁 編程語言 正文
Series屬性
Series屬性列表
屬性 | 說明 |
---|---|
Series.index | 系列的索引(軸標簽) |
Series.array | 系列或索引的數據 |
Series.values | 系列的數據,返回ndarray |
Series.dtype | 返回基礎數據的數據類型 |
Series.shape | 返回基礎數據形狀的元組 |
Series.nbytes | 返回基礎數據占的字節數 |
Series.ndim | 基礎數據的維數,永遠是1 |
Series.size | 返回基礎數據中元素的個數 |
Series.T | 返回轉置,永遠為Series自己 |
Series.memory_usage([index, deep]) | 返回系列的內存使用情況 |
Series.hasnans | 如果有任何 NaN,則返回 True |
Series.empty | 指示 Series是否為空 |
Series.dtypes | 返回基礎數據的數據類型 |
Series.name | 返回系列的名稱 |
Series.flags | 獲取與此 pandas 對象關聯的屬性 |
Series.set_flags(*[,copy,…]) | 返回帶有更新標志的新對象 |
Series屬性詳解
由于Series是一個可以自定義行索引的一維數據,所以Series的屬性大部分都是ndarray的屬性,在ndarray屬性的基礎上有了新的擴展,其中比較重要的是index,values等。詳細介紹示例如下:(建議看不懂說明的可以直接看示例,示例更容易懂)
>>> import numpy as np
>>> import pandas as pd
# 創建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 # 數組
<PandasArray> # 返回的數據類型為PandasArray
[10, 11, 12, 13, 14, 15]
Length: 6, dtype: int16
Series.values
>>> ser01.values # 數據
array([10, 11, 12, 13, 14, 15], dtype=int16) # 返回值為ndarray
Series.dtype
>>> ser01.dtype # 元素的數據類型
dtype('int16')
Series.shape
>>> ser01.shape # 形狀
(6,)
Series.nbytes
>>> ser01.nbytes # 占用多少字節
12
Series.ndim
>>> ser01.ndim # 維度,維數,軸數,秩
1 # 永遠是1,Series是一維數組
Series.T
>>> ser01.T # 轉置,是它本身
a 10
b 11
c 12
d 13
e 14
f 15
Name: class02, dtype: int16
Series.memory_usage([index, deep])
>>> ser01.memory_usage() # 內存使用量
232
Series.hasnans
>>> ser01.hasnans # 是否有空值
False
Series.empty
>>> ser01.empty # 是否為空
False
Series.dtypes
>>> ser01.dtypes # 元素數據類型,同dtype
dtype('int16')
Series.name
>>> ser01.name # ser01的名字
'class02'
Series.flags
>>> ser01.flags # 此 pandas 對象關聯的屬性
<Flags(allows_duplicate_labels=True)>
Series.set_flags(*[,copy,…])
>>> ser01.set_flags() # 返回帶有更新標志的新對象
a 10
b 11
c 12
d 13
e 14
f 15
Name: class02, dtype: int32
需要掌握屬性的名稱和意義,還有屬性的返回值屬于哪種數據類型,是一個什么值。在數據分析或者可視化中會使用Series屬性的返回值作為其他函數的參數使用,因此必須熟練掌握。
原文鏈接:https://blog.csdn.net/shield911/article/details/124372417
相關推薦
- 2022-06-27 在Python中如何讓字典保持有序_python
- 2022-10-03 C語言實現經典排序算法的示例代碼_C 語言
- 2022-03-27 .NET?Core利用動態代理實現AOP(面向切面編程)_實用技巧
- 2022-06-21 Android隨機給出加減乘除的四則運算算術題_Android
- 2022-09-03 pandas?如何保存數據到excel,csv_python
- 2022-12-24 C++中的函數返回值與拷貝用法_C 語言
- 2023-02-05 不同的編程語言輸出?“Hello?World”?代碼_其它綜合
- 2022-06-28 C語言多線程開發中死鎖與讀寫鎖問題詳解_C 語言
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支