Sequence Manipulator Python SequenceIterator Methods

The following sequence manipulator methods take a variety of input sequence arguments and produce result sequences or scalar types as described in the table below:

reverse() Return the object's sequence in reverse order
concat(input) Return the object's sequence concatenated with the input sequence
limit( from, till ) Return the sub-sequence [from,till] of the object's sequence
get( [size] ) Extract data from the object's sequence to a list. If the optional parameter size is specified, limit the list to that length
unget( input, elemtype [, elemsize] ) Iterate through the buffer input previously created with get() to return the result sequence of the type elemtype. The optional parameter elemsize is the length of the buffer.
uniq() Return only the unique elements in the object's ordered sequence by "collapsing duplicates"
norm() Return the normalized values of the object's sequence; i.e. divide each sequence element by the square root of the sum of squares of all elements.
thin( origin, step ) Return the object's sequence "thinned" by selecting elements with the specified origin and step.
diff() Return the sequence consisting of the differences between pairs of the object's sequence elements
const( value, elemtype [,elemsize] ) Return the sequence of the specified type elemtype with elements having the constant value value. The optional parameter elemsize determines the element size for a sequence of type character array
trend()

Return in result sequence the " trend" by comparing pairs of the object's sequence elements the sign of the difference between pairs of non-equal sequence elements. For example, the input sequence {1,2,3,3,2,2,4,5,6,5,5} would produce the result{0,1,1,1,-1,-1,1,1,1,-1,-1}.

tee() Create two iterators for the object's sequence (i.e. fork the sequence iterator). (Note that these iterators should be traversed together (i.e. used in the same expression).
repeat( n_times ) Return the sequence with each element of the object's sequence repeated n_times times
cross( cross_direction ) Return the positions in the object's sequence where it crosses zero. If the integer argument cross_direction is positive then the result sequence starts with the first cross above zero; if negative it starts with cross below zero; if cross_direction is zero then it doesn't matter, i.e. the first cross can be above or below zero.
extrema( first_extremum ) Return the positions of extrema (local minimum and maximums) in the object's sequence. If the integer argument first_extremum is positive then the result sequence starts with first local maximum; if negative it starts with with local minimum; if first_extremum is zero then it doesn't matter.

Example

Following is an example code snippet demonstrating sequence manipulator methods:

     
    cursor = con.cursor("Quote", "by_sym")
    for quote in cursor:
        ...
        cl1,cl2 = quote.close.tee()
            
        avg5_it = cl1.window_agg_avg(5)
        avg20_it = cl2.window_agg_avg(20)
        sub_it = avg20_it.sub(avg5_it)
        cross_it = sub_it.cross(1)
            
        agg_it = quote.day.map(cross_it)
            
        ...