Pandas之Series

简介: 笔记
import pandas as pd
# Series数据结构
# 传入一个列表
S1 =pd.Series(['a','b','c','d'])
print(S1)
# 指定索引
print('................')
S2 =pd.Series([1,2,3,4],index=['a','s','f','d'])
print(S2)
# 传入一个字典
print('................')
S3 =pd.Series({'a':1,'b':2,'c':3})
print(S3)
# 利用index方法获取Series的索引
print('................')
print(S1.index)
print(S2.index)
print(S3.index)
# 利用values方法获取Series的值
print('................')
print(S1.values)
print(S2.values)
print(S3.values)

输出以下内容:

0    a
1    b
2    c
3    d
dtype: object
................
a    1
s    2
f    3
d    4
dtype: int64
................
a    1
b    2
c    3
dtype: int64
................
RangeIndex(start=0, stop=4, step=1)
Index(['a', 's', 'f', 'd'], dtype='object')
Index(['a', 'b', 'c'], dtype='object')
................
['a' 'b' 'c' 'd']
[1 2 3 4]
[1 2 3]
相关文章
|
4月前
|
BI 数据处理 索引
Pandas基本操作:Series和DataFrame(Python)
Pandas基本操作:Series和DataFrame(Python)
321 1
|
4月前
|
索引 Python
Python 教程之 Pandas(11)—— 索引和选择 series 的数据
Python 教程之 Pandas(11)—— 索引和选择 series 的数据
57 0
Python 教程之 Pandas(11)—— 索引和选择 series 的数据
|
4月前
|
索引 Python
Python 教程之 Pandas(10)—— 访问 series 的元素
Python 教程之 Pandas(10)—— 访问 series 的元素
86 0
Python 教程之 Pandas(10)—— 访问 series 的元素
|
4月前
|
存储 SQL 索引
Python 教程之 Pandas(9)—— 创建 Pandas Series
Python 教程之 Pandas(9)—— 创建 Pandas Series
65 0
Python 教程之 Pandas(9)—— 创建 Pandas Series
|
4月前
|
JSON 数据挖掘 数据格式
Pandas中Series、DataFrame讲解及操作详解(超详细 附源码)
Pandas中Series、DataFrame讲解及操作详解(超详细 附源码)
176 0
|
29天前
|
索引 Python
Pandas学习笔记之Series
Pandas学习笔记之Series
|
10月前
|
数据挖掘 Python
【Python】数据分析:结构化数分工具 Pandas | Series 与 DataFrame | 读取CSV文件数据
【Python】数据分析:结构化数分工具 Pandas | Series 与 DataFrame | 读取CSV文件数据
73 1
|
9月前
|
前端开发 Python
Python 教程之 Pandas(12)—— series 的二元运算
Python 教程之 Pandas(12)—— series 的二元运算
59 0
|
9月前
|
前端开发 Python
Python 教程之 Pandas(13)—— series 上的转换操作
Python 教程之 Pandas(13)—— series 上的转换操作
80 0
|
1月前
|
SQL 数据采集 JSON
Pandas 使用教程 Series、DataFrame
Pandas 使用教程 Series、DataFrame
34 0