| | |
Convert python list to numpy array.
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
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
Views: 2075 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Python
abrupt apache application argv beginner binary book calculator change cipher code command compile dictionaries dictionary drive dynamic event examples excel file float format ftp function google gui homework import inches input java keyboard launcher line linux list lists loop maze microphone mouse movingimageswithpygame newb number numbers obexftp output parsing path permissions phonebook plugin port prime program programming projects py2exe pygame pyqt python random recursion recursive refresh remote scrolledtext search session signal simple ssh string strings strip table terminal text thread threading time tkinter tlapse trick tuple tutorial ubuntu unicode unit urllib urllib2 valueerror variable verify vigenere windows wordgame wxpython xlwt






