Actually, none of the proposed solutions worked in my case (Python 2.7.6, NumPy 1.8.2). But I've found out, that change of dtype from complex (standard Python library) to numpy.complex_ may help:

>>> import numpy as np
>>> x = 1 + 2 * 1j
>>> C = np.zeros((2,2),dtype=np.complex_)
>>> C
array([[ 0.+0.j,  0.+0.j],
       [ 0.+0.j,  0.+0.j]])
>>> C[0,0] = 1+1j + x
>>> C
array([[ 2.+3.j,  0.+0.j],
       [ 0.+0.j,  0.+0.j]])
Answer from Lenka42 on Stack Overflow
🌐
IncludeHelp
includehelp.com › python › numpy-creating-a-complex-array-from-2-real-ones.aspx
Python - NumPy: Creating a complex array from 2 real ones?
# Import numpy import numpy as np # Import pandas import pandas as pd # Creating two numpy arrays arr1 = np.array([15, 25, 30]) arr2 = np.array([5, 15, 20]) # Display original arrays print("Original array 1:\n",arr1,"\n") print("Original array 2:\n",arr2,"\n") # Creating a complex array com = np.empty((3,3),dtype=np.complex128) com.real = arr1 com.imag = arr2 # Display result print("Result:\n",com)
🌐
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
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.array.html
numpy.array — NumPy v2.4 Manual
Examples · Try it in your browser! >>> import numpy as np >>> np.array([1, 2, 3]) array([1, 2, 3]) Upcasting: >>> np.array([1, 2, 3.0]) array([ 1., 2., 3.]) More than one dimension: >>> np.array([[1, 2], [3, 4]]) array([[1, 2], [3, 4]]) Minimum dimensions 2: >>> np.array([1, 2, 3], ndmin=2) array([[1, 2, 3]]) Type provided: >>> np.array([1, 2, 3], dtype=complex) array([ 1.+0.j, 2.+0.j, 3.+0.j]) Data-type consisting of more than one element: >>> x = np.array([(1,2),(3,4)],dtype=[('a','<i4'),('b','<i4')]) >>> x['a'] array([1, 3], dtype=int32) Creating an array from sub-classes: >>> np.array(np.
🌐
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
🌐
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?
Find elsewhere
🌐
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 - Write a NumPy program to find the real and imaginary parts of an array of complex numbers · Sample Solution: Python Code: # Importing the NumPy library with an alias 'np' import numpy as np # Calculating square root of a complex number x = np.sqr...
🌐
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 ·
🌐
Delft Stack
delftstack.com › home › howto › numpy › imaginary numbers numpy
Imaginary Numbers in NumPy Arrays | Delft Stack
March 11, 2025 - Learn to create complex number arrays, perform arithmetic operations, and access real and imaginary parts easily. Enhance your numerical computing skills with practical examples and explanations. Ideal for Python enthusiasts and engineers alike, this guide will help you leverage NumPy for complex ...
🌐
DNMTechs
dnmtechs.com › creating-a-complex-array-from-two-real-arrays-in-python-3
Creating a Complex Array from Two Real Arrays in Python 3 – DNMTechs – Sharing and Storing Technology Knowledge
By leveraging the capabilities ... opens up new possibilities for data manipulation and analysis in Python. Example 1: Creating a complex array from two real arrays using the zip() function....
🌐
TutorialsPoint
tutorialspoint.com › article › extracting-the-real-and-imaginary-parts-of-a-numpy-array-of-complex-numbers
Extracting the real and imaginary parts of a NumPy array of complex numbers
July 10, 2023 - Here, my_complex_array is a NumPy array of complex numbers, and real_part and imag_part are arrays containing the real and imaginary parts of the complex numbers in my_complex_array, respectively. In the below example, we create a list of a complex number using the array() function of numpy and then extract the real and imaginary parts of each complex number using the real and imag attributes, respectively...
🌐
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 - 2. log(x ... In this article, we will discuss how to compute the eigenvalues and right eigenvectors of a given square array using NumPy library. Example: Suppose we have a matrix as: [[1,2], [2,3]] Eigenvalue we get from this matrix or ...
🌐
SciPy
docs.scipy.org › doc › › numpy-1.13.0 › reference › generated › numpy.array.html
numpy.array — NumPy v1.13 Manual
Examples · >>> np.array([1, 2, 3]) array([1, 2, 3]) Upcasting: >>> np.array([1, 2, 3.0]) array([ 1., 2., 3.]) More than one dimension: >>> np.array([[1, 2], [3, 4]]) array([[1, 2], [3, 4]]) Minimum dimensions 2: >>> np.array([1, 2, 3], ndmin=2) array([[1, 2, 3]]) Type provided: >>> np.array([1, ...
🌐
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 › complex-numbers-in-python-set-1-introduction
Complex Numbers in Python | Set 1 (Introduction) - GeeksforGeeks
August 21, 2024 - Operations on complex numbers : 1. exp() :- This function returns the exponent of the complex number mentioned in its argument. 2. log(x ... Other than some generic containers like lists, Python in its definition can also handle containers with specified data types. The array can be handled in Python by a module named "array".
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.imag.html
numpy.imag — NumPy v2.4 Manual
If val is real, the type of val is used for the output. 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.imag array([2., 4., 6.]) >>> a.imag = np.array([8, 10, 12]) >>> a array([1.