7. 学习 + 练习
import numpy as np
import pandas as pd
s = pd.Series(np.random.rand(5))
print(s)
print(s[3], type(s[3]), s[3].dtype)
s2 = pd.Series(np.random.rand(5), index=['a', 'b', 'c', 'd', 'e'])
print(s2)
print(s2['a'], type(s2['a']), s2['a'].dtype)
print(s2[['a', 'b']])
print(s2[['b', 'a', 'c']])
s3 = pd.Series(np.random.rand(5), index=['a', 'b', 'c', 'd', 'e'])
print(s3['a': 'c'])
print(s3['c'])
print('------')
s4 = pd.Series(np.random.rand(5))
print(s4[1:3], s4[3])
s5 = pd.Series(np.random.rand(3) * 100)
s5[4] = None
print(s5)
b = s5.isnull()
b1 = s5 > 50
b2 = s5.notnull()
print(b, type(b), b.dtype)
print(b1, type(b1), b1.dtype)
print(b2, type(b2), b2.dtype)
print(s5[s5 > 50])