Python3
quick
arrayname[::-1] # reverse, backwards
zip(*ARRAY) # transpose array
dir(object) # see all attributes
[ (do x) for x in array if x==whatever]
lambda a,b: a+b
pandas
df = pd.Dataframe(data, index=, columns=)
df.sort_values('', ascending=ToF)
pd.concat(df1, df2)
df.rename(columns = {'x': 'y'})
df.drop(columns=['',''])
### loop through files and build 1 df
if isinstance(df, pd.DataFrame):
df = pd.concat([df, nextin], ignore_index=True)
else:
df = nextin
### print n idxs around idx that satisfys condition
idx = df.index.get_indexer_for(condition.index)
print(idx) # array of ids that fit the condition above
n = 2
input(df.iloc[np.unique(
np.concatenate(
[np.arange(max(i-n,0), min(i+n+1, len(df))) for i in idx]))])
(df['v'].shift() != df['v']).cumsum() #split continuous same
df['max_fwd'] = df.price.rolling(window=daysf).max().shift(1 - daysf)
### quick test
print(df.info())
print(df.iloc[:, [columnsints]])
datatypes
a = TestClass(1000)
a.instance_mthd(2)
# Instance method, with 'self': 2000
TestClass.class_mthd(2)
# Class method, with `cls`: 400
a.static_mthd(2)
# Static method, with neither args: 2
pip
which pip
pip show $PACKAGE
pip install $PACKAGE --user
pip list
builtin functions
open
print
compile
eval
exec
input
repr
bytearray
bytes
vars
dir
format
isinstance
callable
issubclass
zip
tuple # immutable seq objtype
map
sorted
list
filter
frozenset
set
iter
reversed
slice
len
range
enumerate
breakpoint
hash
id
next
object
bin
oct
hex
int
chr
str
ord
ascii
bool
float
complex
dict
divmod
max
min
pow
round
all
any
@property
getattr
hasattr
delattr
type
@staticmethod
@classmethod
super
globals
locals
help
useful libraries
hashlib
concurrent.futures
argparse
functools
numba
asyncio