pandas Series模块知识点
代码笔记:
# -*- coding: utf-8 -*- # @Time : 2/7/2022 # @Athor : WuHe # @File : pandasSeriesRecode.py import pandas as pd # s=pd.Series(data,index,dtype,copy) def empty_series(): s = pd.Series() print('1.this is empty Series:') print(s) ''' Series([], dtype: float64) ''' def create_series(): s = pd.Series([1, 2, 3, 4, 5, 6, 7], index=['a', 'b', 'c', 'd', 'e', 'f', 'g', ]) print('2.this is a create Series:') print(s) ''' a 1 b 2 c 3 d 4 e 5 f 6 g 7 dtype: int64 ''' print('3.this is section切片【0-3】 read:') print(s[:3]) ''' a 1 b 2 c 3 dtype: int64 ''' print('4.return all index:') print(s.axes) ''' [Index(['a', 'b', 'c', 'd', 'e', 'f', 'g'], dtype='object')] ''' print('5.查看对象是否为空:') print(s.empty) ''' False ''' print('6.查看对象的维数,series始终是1维:') print(s.ndim) ''' 1 ''' print('7.查看对象长度:') print(s.size) ''' 7 ''' print('8.以数组方式查看serise:') print(s.values) ''' [1 2 3 4 5 6 7] ''' print('9.查看index的范围:') print(s.index) ''' Index(['a', 'b', 'c', 'd', 'e', 'f', 'g'], dtype='object') ''' print('10.查看前3行,缺省默认5行:') print(s.head(3)) ''' a 1 b 2 c 3 dtype: int64 ''' print('11.查看后3行,缺省默认5行:') print(s.tail(3)) ''' e 5 f 6 g 7 dtype: int64 ''' print('12.检测缺失项isnull,notnull结果相反:') print(pd.isnull(s)) ''' a False b False c False d False e False f False g False dtype: bool ''' if __name__ == '__main__': empty_series() create_series()
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类