lun. 04 octobre 2010

Numpy tips

np.where(np.diff(np.sign(x)))[0] Find points of x crossing the threshold T : np.where(np.diff(x > T))[0] Find points of x crossing threshold ascending : np.where(np.diff(x > T) & (x[1:] > T)) Remove points that are close, i.e. given a sorted array …

lun. 04 octobre 2010

Python tips

Datetime Get the current date/time and format it (e.g. to create a filename) : import datetime print(datetime.datetime.now().strftime('%d%b%Y-%Hh%M')) >> '10Oct2018-18h01' See Comportement de strftime() et strptime() for the availables directives