# -*- encoding:utf-8 -*- # Copyright (c) 2015 Shiye Inc. # All rights reserved. # # Author: ldq <liangduanqi@shiyejinrong.com> # Date: 2019/2/12 9:26 import numpy as np import pandas as pd s = pd.Series() ''' 创建一个空序列 Series([], dtype: float64) ''' data1 = np.array(["a", "b", "c", "d"]) s1 = pd.Series(data1) ''' 0 a 1 b 2 c 3 d dtype: object ''' s10 = pd.Series(data1, index=range(100, 104)) ''' index参数为一个可迭代集合 100 a 101 b 102 c 103 d dtype: object ''' data11 = {"a": 0., "b": 1., "c": 2.} s11 = pd.Series(data11) ''' 字典的key用于构建索引 a 0.0 b 1.0 c 2.0 dtype: float64 ''' s12 = pd.Series(data11, index=["b", "c", "d", "a"]) ''' b 1.0 c 2.0 d NaN a 0.0 dtype: float64 ''' s2 = pd.Series(5, index=[0,1,2,3]) ''' 0 5 1 5 2 5 2 5 dtype: int64 ''' a = s2[1] b = s2[1:] ''' 类似python的list可被切片 1 5 2 5 3 5 dtype: int64 ''' c = s2[[0,1,2]] ''' 使用索引标签值列表检索多个元素 0 5 1 5 2 5 dtype: int64 '''