ceil | ceil value of the input elements |
floor | floor value of the input elements |
radians | Convert angels degree to radians |
rad2deg | Convert radians to degree |
round | Rounding off to nearest decimal point |
import numpy as np
arr = np.array([1.0, np.nan, np.inf, -np.inf, 4.0])
print("Original:", arr)
print("isfinite:", np.isfinite(arr))
print("nanmean (ignores nan):", np.nanmean(arr))
print("clip finite values between 0 and 10:", np.clip(arr, 0, 10))
np.isfinite to check finite elements.np.nanmean.np.clip to bound values, useful in many data processing tasks.import numpy as np
z = np.array([1 + 2j, 3 - 4j, -2 + 0.5j])
print("Real parts:", np.real(z))
print("Imag parts:", np.imag(z))
print("Angles (in radians):", np.angle(z))
print("Magnitude:", np.abs(z))
import numpy as np
import time
N = 1000000
arr = np.arange(N, dtype=np.float64)
start = time.time()
res_np = np.sqrt(arr)
print("NumPy sqrt time:", time.time() - start)
start2 = time.time()
res_loop = [x**0.5 for x in arr]
print("Python loop sqrt time:", time.time() - start2)
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.