pandas 简单系列创建示例
示例
系列是一维数据结构。这有点像一个增压数组或字典。
import pandas as pd s = pd.Series([10, 20, 30]) >>> s 0 10 1 20 2 30 dtype: int64
系列中的每个值都有一个索引。默认情况下,索引是整数,从0到序列长度减去1。在上面的示例中,您可以看到打印在值左侧的索引。
您可以指定自己的索引:
s2 = pd.Series([1.5, 2.5, 3.5], index=['a', 'b', 'c'], name='my_series')
>>> s2
a 1.5
b 2.5
c 3.5
Name: my_series, dtype: float64
s3 = pd.Series(['a', 'b', 'c'], index=list('ABC'))
>>> s3
A a
B b
C c
dtype: object
热门推荐
1 狗狗技能训练
5 如何训练狗狗笑
6 狗狗训练排便
9 狗狗响片训练
10 如何训练狗狗不捡食
11 狗狗尿训练
12 怎么训练狗狗找东西
13 狗狗训练站立
14 狗狗训练飞盘
15 鞍山狗狗训练
16 怎样训练泰迪狗狗谢谢
17 狗狗外出训练
18 怎么训练金毛狗狗大小便