1.创建Series
1.1 根据列表创建
# 根据列表创建
list=["a","b","c"]
s=pd.Series(list)
s.index # 输出0 1 2
s.values # 输出a b c
# 将第二个值修改为d
s[1]="d"
1.2 根据数组创建
# 根据字典创建
dic = {"a":1,"b":2,"c":3}
s=pd.Series(dic)
s.index # 输出a b c
s.values # 输出1 2 3
1.3 切片
s1= pd.Series([6,7,8,9,10],index = ['a','b','c','d','e'])
s1["b":"d"] #输出b c d 行
s1[1:3] # 输出b c 行
1.4 删除与添加
s = pd.Series(np.random.rand(5),index=list("abcde"))
# 删除a那一行
s1 = s.drop("a",inplace=True)
# 增加a那一行
s["a"]=100
ps.s1+s2执行的是对齐运算
s1 = pd.Series(np.random.rand(3), index=["Kelly","Anne","T-C"])
s2 = pd.Series(np.random.rand(3), index=["Anne","Kelly","LiLy"])
print("===================")
print(s1)
print("===================")
print(s2)
print("=======&