# Similar list
import numpy
import pandas
s = pandas.Series(numpy.random.rand(5))
print(s[4])
label
import numpy
import pandas
s = pandas.Series(numpy.random.rand(3),index = ['a','b','c'])
print(s)
# Method is similar to subscript index , use [] Express , It says index, Be careful index Is string
print(s["b"])
# If you need to select the value of multiple labels , use [[]] To express ( amount to [] Contains a list )
# The result of the multi label index is a new array
sr = s[["b","a"]]
print(sr)
section
import numpy
import pandas
s1 = pandas.Series(numpy.random.rand(5))
s2 = pandas.Series(numpy.random.rand(3),index = ["a","b","c"])
print(s1[1:4]) # Subscript , Left closed right away
print(s2["a":"c"]) # label , Left and right closed
# If index Is the number , Priority defaults to subscript
# Slice the subscript index , Same as list writing
print(s2[:-1])
print(s2[::2]) # The stride is 2
Boolean type
import numpy
import pandas
s = pandas.Series(numpy.random.rand(3)*100)
s[4] = None # Add a null value
print(s)
bs1 = s > 50 # Judge whether it is greater than 50
bs2 = s.isnull() # yes null
bs3 = s.notnull() # No null
print(bs1)
print(bs2)
print(bs3)
# After the array makes a judgment , What is returned is a new array of Boolean values
# .isnull() / .notnull() Judge whether it is a null value
# None For null ,NaN Represents the value in question , Both will be recognized as null
# Boolean index method : use [ Judge the condition ] Express
# The judgment condition can be a statement , Or a Boolean array
print(s[s > 50])
print(s[bs3])