0

The title kind of says it all. I have this (excerpt):

import numpy as np
import matplotlib.pyplot as plt

number_of_particles=1000

phi = np.arccos(1-2*np.random.uniform(0.0,1.,(number_of_particles,1)))
vc=2*pi
mux=-vc*np.sin(phi)

and I get out

[[-4.91272413]
 [-5.30620302]
 [-5.22400513]
 [-5.5243784 ]
 [-5.65050497]...]

which is correct, but I want it to be in the format

[-4.91272413 -5.30620302 -5.22400513 -5.5243784 -5.65050497....]

Feel like there should be a simple solution, but I couldn't find it.

Mckenzie
  • 25
  • 1
  • 1
  • 8

3 Answers3

0

Suppose your array is represented by the variable arr. You can do,

l = ''
for i in arr:
   l = l+i+' '
arr = [l]
Abhilash V
  • 69
  • 3
0

Use this command:

 new_mux = [i[0] for i in mux]

But I need it in an array, so then I add this

new_mux=np.array(new_mux)

and I get the desired output.

Mckenzie
  • 25
  • 1
  • 1
  • 8
0

There's a method transpose in numpy's array object

 mux.transpose()[0]
a.l.
  • 985
  • 11
  • 27