PD PANDAS AS Import
'' '
Series sequence:
1. The sequence of statements specified index column labels
2. See column index (index), and elements (values)
3. Select the inner element
4. The element is assigned
5. Defining a new array Numpy Series object
6. filter element
7.Series objects and computing mathematical functions
8.Series constituent elements (repeat, whether or not there)
9.NaN
10.Series used dictionaries
' ''
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
# ## 1. Declare Series, and specify an index (not specified: automatically increments the index starts from 0) series_define pd.Series = ([2,3,3,4,6,8], index = [ ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' ]) Print (series_define) ' '' A 2 B. 3 C. 3 D. 4 E. 6 F. 8 DTYPE: Int64 '' '
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
# ## Series 2. Check sequence index and [element] two arrays series_index = series_define.index series_value = series_define.values Print (series_index) Print (series_value) '' ' Index ([' A ',' B ', 'C', 'D', 'E', 'F'], DTYPE = 'Object') [2. 8. 6. 4. 3. 3] '' '
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
# ## 3. Select Internal elements: Specifies the label slice or Print (series_define [-1 ]) Print (series_define [. 4: -1 ]) Print (series_define [ ' F ' ]) Print (series_define [[ ' E ' , ' F ' ]]) # when ## takes a plurality of values through the label, the label put on the array
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
# ## 4. element assignment: = elements selected assignment series_define [0] = 66 series_define [ ' B ' ] = 77 Print (series_define) '' ' A 66 B 77 C. 3 D. 4 E. 6 F. 8 DTYPE: Int64 ' ''
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
# ## The existing array generating Series ARR = np.array ([1,2,3,4 ]) S = pd.Series (ARR) Print (S) '' ' 0. 1 . 1 2 2. 3 . 3. 4 DTYPE : Int32 '' '
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
# ## 6. Filter element: obtaining the element s is greater than 3 [s> 3] Print (s [s> 3])
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
# ## 7 applied to the array Numpy operator (+ - * /) and np.log () and the like are suitable mathematical function # division S1 = series_define / 2 Print (S1) '' ' A 33.0 B 38.5 C for 1.5 2.0 D E 3.0 F 4.0 DTYPE: float64 '' ' # taking the S2 = np.log (series_define) Print (S2) ' '' A 4.189655 B 4.343805 C 1.098612 D 1.386294 E 1.791759 F 2.079442 DTYPE: float64 '' '
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
# # 8. repetitions and determines whether there is # .unique () to weight (no duplicate elements, an array of return value) S_A pd.Series = ([1,1,1,1,2,2,2,3 ] ) a = s_a.unique () Print (a) '' ' [2. 3. 1] ' '' # .value_counts () returns the element to the weight, and the number of statistics appear: returns Series, as the number of occurrence values b = s_a.value_counts () Print (B) Print (B [. 1 ]) # .isin () determines whether there is (a Boolean return value) C = s_a.isin ([2,3 ]) Print (C) C1 = S_A [ s_a.isin ([2,3 ])] Print (C) Print (C1) '' ' 0 False . 1 False 2 False 3 False 4 True 5 True 6 True 7 True dtype: bool 0 False 1 False 2 False 3 False 4 True 5 True 6 True 7 True dtype: bool 4 2 5 2 6 2 7 3 dtype: int64 '''