The pandas Series is much more powerful than the numpy array , in many ways
First, the pandas Series has some methods, such as:
The describe method can give some analysis data of Series :
Import= PD. Series ([1,2,3,4]) d = s.describe ()
Print (d)
Count 4.000000mean 2.500000std 1.290994min 1.00000025% 1.75000050% 2.50000075% 3.250000max 4.000000dtype:float64
Second, the biggest difference between the Pandas series and the numpy array is that the Pandas series has an ' index ' concept:
When you create a Pandas series, you can include an array of index values:
Life = PD. Series ([74.7, 72.8], index=['city1'city2' city3"city4")
Print (Life)
where [' city1 ', ' city2 ', ' city3 ', ' City4 '] array is an indexed array that will be indexed as a life Series :
City1 74.7city2 75.0city3 80.0city4 72.8dtype: Float64
Pandas Series is a combination of list and dict , list is ordered, according to position 0,1,2,3 ... to get the corresponding position of the element, dict is unordered, by key to get the corresponding element, pandas Series is both ordered and indexed key , you can get the element by key :
Print (life['city1') # result 74.7
You can also get elements by location index:
Print (life[0]) # result 74.7
To better differentiate between positional and key indexes, the pandas Series provides two methods:
Print (life.loc['city1') Print (Life.iloc[0])
Loc passes in the key index value, iloc the location index value.
Pandas Array (Pandas Series)-(2)