From 092c550b67fb80bcd63cb813babe4d7bb4471547 Mon Sep 17 00:00:00 2001 From: Rupa-Rd Date: Mon, 20 May 2024 22:32:10 +0530 Subject: [PATCH] Example for complex type is added --- contrib/numpy/datatypes.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/contrib/numpy/datatypes.md b/contrib/numpy/datatypes.md index ea9430b..8bf52ad 100644 --- a/contrib/numpy/datatypes.md +++ b/contrib/numpy/datatypes.md @@ -128,7 +128,22 @@ Note: `np.single()` has the same function as `float32()`. # 1 # uint32 ``` + ## Example for complex type +Complex type is a combination of real number + imaginary number. The `complex_()` is used to define the complex type NumPy object. +``` python + import numpy as np + + x = np.complex_(1) + # Size: complex64, complex128 + + print(x) + print(x.dtype) + + # Output: + # (1+0j) + # complex128 +``` ## Example for datetime type