Algorithms, functions, classes, regular expressions, iterators, generators, OOP, exceptions, NumPy, pandas, scikit-learn
https://telega.in/c/python_tasks
Questions — @dina_ladnyuk
Post #983
4.2K
PY @python_tasks
Showing posts older than #985 · Back to latest
import numpy as np
a = np.array([True, False])
print(np.all(a), np.any(a))
import numpy as np
r = np.array([3, 4, 5])
import numpy as np
a = np.array([[0], [1]])
b = np.array([[1], [-1]])
import numpy as np
a = np.array([[0], [1]])
b = np.array([[1], [-1]])
import numpy as np
a = [('x', 6.0, 1), ('y', 5.0, 2), ('z', 5.0, 3)]
dtype = [('val', 'S1'), ('float', 'f8'), ('int', 'i4')]
b = np.array(a, dtype=dtype)
b.sort(order=['float', 'int'])
print(b[1][0].decode())
import numpy as np
dt = np.dtype([('x', 'f8')])
a = np.zeros(4, dtype=dt)
a['x'] = np.array((0., 1., 2., 3.))
print(a['x'][2] + a['x'][3])
import numpy as np
a = np.ones(2, dtype='int8,float32,complex')
a[0][0] = 2
a[1][1] = 3
a[0][2] = 4j
print(sum(a[0]).imag + sum(a[1]).real)
import numpy as np
a = np.array([1, 2, 3, 4])
b = np.searchsorted(a, 3.5)
print(b)
import numpy as np
a = np.array([30, 0, -1, 7])
x = np.argsort(a)
print(x[0])