On the third day of learning sequence python

Creating a sequence

First, create a package and loading sequence of functions required

from pandas import Series;

  Defined sequence, can be defined mixing

x = Series ([ 'a' , True, 1], index = [ 'first', 'second', 'third']); 
or is not defined sequence name, Default: 
X = Series ([ 'A', to true, 1]);

  Access sequence

# 1, the access sequence number, not stomping 

X [ 'SECOND'] 

# 2, access position according to 

x [3]

  Additive element in the sequence

# Is not a single element is added, sequence values may be added 

x.append (n) # so can not run 

# append a sequence of 

n-Series = ([ '2']) 
x.append (n-) 

# changes need to carry a variable 

x = x .append (n) # appended to the rearmost existing sequence begins again to 0 

x [[0,2]] # positioning acquisition, commonly used in the random sampling

  Sequence deleting data

x.drop (2) # delete the index index 

x.drop (x.index [3]) # delete the position 

x [ '2'! = x.values ] # The value of the delete

  

Guess you like

Origin www.cnblogs.com/manjianlei/p/11266225.html