Show Menu
Cheatography

Lists - Python and Q Cheat Sheet (DRAFT) by

List operations by Ptyhon and Q

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Modifi­cation

oper­ation
Python
Q
adding item
l.app­end(3)
l,: 3
insert
l.ins­ert(i, 7)
l: (i#l), 7, i _ l
delete all
l.cle­ar()
l: 0#l
pop
l.pop()
l: -1 _ l
remove single
l.rem­ove(3)
l: l except 3
remove multiple
[e for e in l1 if e not in l2]
l: l except l2
deleteby index
del l[3]
l: l _ 3

Simila­rities on general list

oper­ation
Python
Q
length
len(l)
count t
reve­rse
list(­rev­ers­e(l))
reverse l
first part
l[:2]
2#l
last part
l[-2:]
-2#l
middle part
l[1:3]
1_3#l
 

operations on list of numbers

oper­ation
Python
Q
minu­mum
min(l)
min l
aver­age
stati­sti­cs.m­ea­n(l)
avg l
vari­ance
stati­sti­cs.v­ar­ian­ce(l)
svar l
cumm­ulative sum
list(­ite­rto­ols.ac­cum­ula­te(l, operat­or.a­dd))
sums l
cumm­ulative prod
list(­ite­rto­ols.ac­cum­ula­te(l, operat­or.m­ul))
prds l

Split and Join

oper­ation
Python
Q
join
",".j­oi­n(l)
"," sv l
split
s.spl­it(­"­,")
"," vs s