pd.Series用法
A. 首先需要载入pandas 和numpy如下:
import pandas as pd
import numpy as np
B. 接着定义一个pd.Series序列并输出:
s1 = pd.Series((1,2,3,4,5))
print(s1)
输出如下:
0 1
1 2
2 3
3 4
4 5
dtype: int64
C. s1的值:
s1.values
输出为:array([1, 2, 3, 4, 5], dtype=int64)
D. s1的索引:
s1.index
输出为:RangeIndex(start=0, stop=5, step=1)
E.s1的索引:
s1[3]
F. 用另一种方式定义pd.Series
s2 = pd.Series([1,2,3,4,5],index = ['a','b'