| | |
Convert python list to numpy array.
Thread Solved |
Is there an easy way of doing this? for example my list is:
or is it impossible to place objects, such as a sphere from vpython into a numpy array?, perhaps i could just put the x,y co-ordinates into a numpy array?
python Syntax (Toggle Plain Text)
nlat=10 mylist = [] for x in range(0,nlat): for y in range(0,nlat): disk=sphere(pos=(x*s,y*s), radius = r, color=(0,1,9)) mylist.append(disk)
or is it impossible to place objects, such as a sphere from vpython into a numpy array?, perhaps i could just put the x,y co-ordinates into a numpy array?
•
•
Join Date: Jul 2006
Posts: 608
Reputation:
Solved Threads: 150
Lists of lists work fine as container arrays (not mathematical arrays, but you don't seem to be wanting that). So:
et voila! An array of spheres.
Jeff
Python Syntax (Toggle Plain Text)
nlat=10 mylist = [] for x in range(0,nlat): tmp = [] for y in range(0,nlat): disk=sphere(pos=(x*s,y*s), radius = r, color=(0,1,9)) tmp.append(disk) mylist.append(tmp)
et voila! An array of spheres.
Jeff
I was wanting to extract a list of x and y values from the list. I did it like this simply:
Solved!
python Syntax (Toggle Plain Text)
x_list = [] y_list = [] for disk in array: x_list.append(disk.x) y_list.append(disk.y)
Solved!
![]() |
Similar Threads
- Converting list of strings to Numpy array of integers (Python)
- Python - statistical functions + a list (Python)
Other Threads in the Python Forum
- Previous Thread: Help creating functions
- Next Thread: How do i use the wxpython.scrolledPanel widget
| Thread Tools | Search this Thread |
abrupt alarm ansi anti approximation assignment avogadro backend beginner binary bluetooth calculator character cmd code customdialog cx-freeze data decimals dictionaries dictionary directory dynamic error examples exe file float format function gnu graphics gui halp heads homework http ideas import input java launcher leftmouse line linux list lists loop module mouse number numbers output parsing path pointer port prime programming progressbar projects push py2exe pygame pyglet pyqt python random recursion schedule screensaverloopinactive script scrolledtext sqlite statistics string strings sudokusolver sum table terminal text thread threading time tlapse tricks tuple tutorial twoup ubuntu unicode urllib urllib2 variable ventrilo wikipedia write wxpython xlib






