Python Forum

Full Version: Creating 2D Array
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

My code is the following:
import numpy
import math
a = numpy.arange(1, 11)
b = numpy.arange(0, .02, .001)
v = []
for c in a:
    v.append([])
    for d in b:
         numpy.append(v[c],(1 / c ** 2) * math.exp( -c ** 2 * math.pi ** 2 * d))
I'm looking to create an a x b array composed of the following:

Output:
a[0]b[0] a[0]b[1] a[0]b[2] etc. a[1]b[0] a[1]b[1] a[1]b[2] etc. a[2]b[0] a[2]b[1] a[2]b[2] etc. etc. etc. etc. etc.
How would I do this? As is my code is producing TypeError: list indices must be integers or slices, not numpy.float64.

Thanks,
Jonathan
I'd use a Pandas dataframe