Functions | |
def | abut |
=========================== LIST FUNCTIONS ========================== | |
def | colex |
def | collapse |
def | dm |
def | duplicates |
def | flat |
def | linedelimited |
def | lineincols |
def | lineincustcols |
def | linexand |
def | linexor |
def | list2string |
def | makelol |
def | makestr |
def | nonrepeats |
def | pl |
def | printcc |
def | printincols |
def | printl |
def | recode |
def | remap |
def | replace |
def | roundlist |
def | simpleabut |
def | sortby |
def | unique |
Variables | |
float | __version__ = 0.4 |
def pstat.abut | ( | source, | |
args | |||
) |
=========================== LIST FUNCTIONS ==========================
Here are the list functions, DEFINED FOR ALL SYSTEMS. Array functions (for NumPy-enabled computers) appear below.
Like the |Stat abut command. It concatenates two lists side-by-side and returns the result. '2D' lists are also accomodated for either argument (source or addon). CAUTION: If one list is shorter, it will be repeated until it is as long as the longest list. If this behavior is not desired, use pstat.simpleabut(). Usage: abut(source, args) where args=any # of lists Returns: a list of lists as long as the LONGEST list past, source on the 'left', lists in <args> attached consecutively on the 'right'
def pstat.colex | ( | listoflists, | |
cnums | |||
) |
Extracts from listoflists the columns specified in the list 'cnums' (cnums can be an integer, a sequence of integers, or a string-expression that corresponds to a slice operation on the variable x ... e.g., 'x[3:]' will colex columns 3 onward from the listoflists). Usage: colex (listoflists,cnums) Returns: a list-of-lists corresponding to the columns from listoflists specified by cnums, in the order the column numbers appear in cnums
def pstat.collapse | ( | listoflists, | |
keepcols, | |||
collapsecols, | |||
fcn1 = None , |
|||
fcn2 = None , |
|||
cfcn = None |
|||
) |
Averages data in collapsecol, keeping all unique items in keepcols (using unique, which keeps unique LISTS of column numbers), retaining the unique sets of values in keepcols, the mean for each. Setting fcn1 and/or fcn2 to point to a function rather than None (e.g., stats.sterr, len) will append those results (e.g., the sterr, N) after each calculated mean. cfcn is the collapse function to apply (defaults to mean, defined here in the pstat module to avoid circular imports with stats.py, but harmonicmean or others could be passed). Usage: collapse (listoflists,keepcols,collapsecols,fcn1=None,fcn2=None,cfcn=None) Returns: a list of lists with all unique permutations of entries appearing in columns ("conditions") specified by keepcols, abutted with the result of cfcn (if cfcn=None, defaults to the mean) of each column specified by collapsecols.
def pstat.dm | ( | listoflists, | |
criterion | |||
) |
Returns rows from the passed list of lists that meet the criteria in the passed criterion expression (a string as a function of x; e.g., 'x[3]>=9' will return all rows where the 4th column>=9 and "x[2]=='N'" will return rows with column 2 equal to the string 'N'). Usage: dm (listoflists, criterion) Returns: rows from listoflists that meet the specified criterion.
def pstat.duplicates | ( | inlist | ) |
def pstat.flat | ( | l | ) |
def pstat.linedelimited | ( | inlist, | |
delimiter | |||
) |
def pstat.lineincols | ( | inlist, | |
colsize | |||
) |
def pstat.lineincustcols | ( | inlist, | |
colsizes | |||
) |
Returns a string composed of elements in inlist, with each element right-aligned in a column of width specified by a sequence colsizes. The length of colsizes must be greater than or equal to the number of columns in inlist. Usage: lineincustcols (inlist,colsizes) Returns: formatted string created from inlist
def pstat.linexand | ( | listoflists, | |
columnlist, | |||
valuelist | |||
) |
Returns the rows of a list of lists where col (from columnlist) = val (from valuelist) for EVERY pair of values (columnlist[i],valuelists[i]). len(columnlist) must equal len(valuelist). Usage: linexand (listoflists,columnlist,valuelist) Returns: the rows of listoflists where columnlist[i]=valuelist[i] for ALL i
def pstat.linexor | ( | listoflists, | |
columnlist, | |||
valuelist | |||
) |
Returns the rows of a list of lists where col (from columnlist) = val (from valuelist) for ANY pair of values (colunmlist[i],valuelist[i[). One value is required for each column in columnlist. If only one value exists for columnlist but multiple values appear in valuelist, the valuelist values are all assumed to pertain to the same column. Usage: linexor (listoflists,columnlist,valuelist) Returns: the rows of listoflists where columnlist[i]=valuelist[i] for ANY i
def pstat.list2string | ( | inlist, | |
delimit = ' ' |
|||
) |
def pstat.makelol | ( | inlist | ) |
def pstat.makestr | ( | x | ) |
def pstat.nonrepeats | ( | inlist | ) |
def pstat.pl | ( | listoflists | ) |
def pstat.printcc | ( | lst, | |
extra = 2 |
|||
) |
Prints a list of lists in columns, customized by the max size of items within the columns (max size of items in col, plus 'extra' number of spaces). Use 'dashes' or '\\n' in the list-of-lists to print dashes or blank lines, respectively. Usage: printcc (lst,extra=2) Returns: None
def pstat.printincols | ( | listoflists, | |
colsize | |||
) |
def pstat.printl | ( | listoflists | ) |
def pstat.recode | ( | inlist, | |
listmap, | |||
cols = None |
|||
) |
Changes the values in a list to a new set of values (useful when you need to recode data from (e.g.) strings to numbers. cols defaults to None (meaning all columns are recoded). Usage: recode (inlist,listmap,cols=None) cols=recode cols, listmap=2D list Returns: inlist with the appropriate values replaced with new ones
def pstat.remap | ( | listoflists, | |
criterion | |||
) |
Remaps values in a given column of a 2D list (listoflists). This requires a criterion as a function of 'x' so that the result of the following is returned ... map(lambda x: 'criterion',listoflists). Usage: remap(listoflists,criterion) criterion=string Returns: remapped version of listoflists
def pstat.replace | ( | inlst, | |
oldval, | |||
newval | |||
) |
def pstat.roundlist | ( | inlist, | |
digits | |||
) |
def pstat.simpleabut | ( | source, | |
addon | |||
) |
Concatenates two lists as columns and returns the result. '2D' lists are also accomodated for either argument (source or addon). This DOES NOT repeat either list to make the 2 lists of equal length. Beware of list pairs with different lengths ... the resulting list will be the length of the FIRST list passed. Usage: simpleabut(source,addon) where source, addon=list (or list-of-lists) Returns: a list of lists as long as source, with source on the 'left' and addon on the 'right'
def pstat.sortby | ( | listoflists, | |
sortcols | |||
) |
def pstat.unique | ( | inlist | ) |
float pstat::__version__ = 0.4 |