Yes, use astype():

In [6]: b = a.astype(complex)
In [7]: b
Out[7]: array([ 1.+0.j,  2.+0.j,  3.+0.j])

In [8]: b.dtype
Out[8]: dtype('complex128')
Answer from xnx on Stack Overflow
🌐
GitHub
github.com › numpy › numpy › issues › 16039
Efficient way to create a complex array from two real arrays · Issue #16039 · numpy/numpy
April 22, 2020 - Dear NumPy developers, This may be more like a question. I have two real arrays (a and b), and I would like create a complex array (c) which takes the two real arrays as its real and imaginary parts respectively. The simplest one would b...
Author   zhcui
🌐
IncludeHelp
includehelp.com › python › numpy-creating-a-complex-array-from-2-real-ones.aspx
Python - NumPy: Creating a complex array from 2 real ones?
For this purpose, we will first create an empty NumPy array of some specific shape and also, and we will define the data type of this array as complex128. Then we will assign the real and imaginary parts of this array as A and B. ... # Import numpy import numpy as np # Import pandas import ...
🌐
GitHub
github.com › numpy › numpy › issues › 11993
Python 3.7 can cast object to complex type · Issue #11993 · numpy/numpy
September 19, 2018 - import numpy as np print(np.__version__) arr = np.array(['AAAAA', 18465886.0, 18465886.0], dtype=object) print(arr.astype(np.complex64)) print(arr.astype(np.complex64)) Python3.6 works as I would expect (complains that it cannot convert a string to complex dtype)
Author   bear24rw
🌐
MathWorks
mathworks.com › matlabcentral › answers › 2136043-how-do-i-put-matlab-complex-array-to-python
how do i put MATLAB complex array to python? - MATLAB Answers - MATLAB Central
July 10, 2024 - Since each complex number can be represented as a tuple of its real and imaginary parts, you can you this and represent it in the form of tuples, that Python can understand. After passing it to Python, this can then be converted back to a complex array using "numpy".
🌐
YouTube
youtube.com › watch
How to create an array of complex numbers in Python - YouTube
How to create an array of complex numbers in Python
Published   July 4, 2021
🌐
Moonbooks
moonbooks.org › Articles › How-to-create-a-matrix-of-complex-numbers-in-python-using-numpy-
How to create a matrix of complex numbers in python using numpy ?
November 15, 2019 - Examples of how to create a matrix of complex numbers in python using numpy: Table of contents · Create a matrix of random numbers · Create a matrix of random numbers with 0+0j · Create a matrix of random complex numbers · References · >>> Z = np.array([[1+2j,1+3j],[5+6j,3+8j]]) >>> Z array([[ 1.+2.j, 1.+3.j], [ 5.+6.j, 3.+8.j]]) >>> import numpy as np >>> Z = np.zeros(10, dtype=complex) >>> Z array([ 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j]) Another example ·
Find elsewhere
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.real.html
numpy.real — NumPy v2.4 Manual
If val has complex elements, the returned type is float. ... Try it in your browser! >>> import numpy as np >>> a = np.array([1+2j, 3+4j, 5+6j]) >>> a.real array([1., 3., 5.]) >>> a.real = 9 >>> a array([9.+2.j, 9.+4.j, 9.+6.j]) >>> a.real = np.array([9, 8, 7]) >>> a array([9.+2.j, 8.+4.j, 7.+6.j]) >>> np.real(1 + 1j) 1.0
🌐
GeeksforGeeks
geeksforgeeks.org › extracting-the-real-and-imaginary-parts-of-an-numpy-array-of-complex-numbers
Extracting the real and imaginary parts of an NumPy array of complex numbers - GeeksforGeeks
September 2, 2020 - Now we will see how to construct complex number in pytorch using torch.complex() method with the given input as real and imaginary numbers. Syntax: torch.complex(real, imag) Parameter: ... In this article, we will discuss how to compute the ...
🌐
Delft Stack
delftstack.com › home › howto › numpy › imaginary numbers numpy
Imaginary Numbers in NumPy Arrays | Delft Stack
March 11, 2025 - In this tutorial, we explored how to store and manipulate imaginary numbers in NumPy arrays. We learned how to create arrays with complex numbers, perform mathematical operations, and access their real and imaginary components. NumPy’s capabilities make it an excellent choice for anyone looking to work with complex numbers in Python.
🌐
Python.org
discuss.python.org › ideas
Complex numbers support in array module - Ideas - Discussions on Python.org
March 7, 2023 - I know about numpy, but I would really like to see it in the built-in python module, but I was wondering if this could be a thing. Any thoughts about this?
🌐
w3resource
w3resource.com › python-exercises › numpy › python-numpy-exercise-15.php
NumPy: Find the real and imaginary parts of an array of complex numbers - w3resource
August 29, 2025 - Original array:x [ 1.+0.j] Original array:y [ 0.70710678+0.70710678j] Real part of the array: [ 1.] [ 0.70710678] Imaginary part of the array: [ 0.] [ 0.70710678] ... x = np.sqrt([1+0j]): Calculates the square root of the complex number (1+0j) and stores the result in the variable ‘x’.