1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| from pandas import Series import numpy as np
def series_test(): """ Series数据结构,由一组数据,以及与之相关的索引构成 Series有序,索引可以唯一,也可以不唯一 """
ori_ser = Series([10, 20, 30, 40, 50, 60])
ori_ser_2 = Series([4, -1, 8, 5], index=['a', 'b', 'c', 'd'])
ori_ser_3 = Series({'a': 0, 'b': 1, 'c': 2, 'd': np.NAN})
obj_a = Series([1, 2, np.NAN, 4], index=['a', 'b', 'c', 'd']) obj_b = Series([1, np.NAN, 3, 4], index=['a', 'b', 'd', 'e'])
ori_ser_3.index = ['aa', 'bb', 'cc', 'dd']
new_ori_ser_2 = ori_ser_2.drop('a')
print('here')
|