I have a 2D array. Say it is 10x10 and I want a 1D Array of 100
elements...
What is the syntax?
oneD = reshape(twoD, (100,1))
or
oneD = reshape(twoD, (1,100))
One I guess is the transpose of the other but both seem to be
arrays of arrays...
help?! 4 12333
KraftDiner wrote: I have a 2D array. Say it is 10x10 and I want a 1D Array of 100 elements... What is the syntax?
oneD = reshape(twoD, (100,1)) or oneD = reshape(twoD, (1,100))
One I guess is the transpose of the other but both seem to be arrays of arrays...
The mailing list for numpy is nu****************@lists.sourceforge.net, and you
may get faster/better help there. But:
oneD = reshape(twoD, (100,))
--
Robert Kern ro*********@gmail.com
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
KraftDiner wrote: I have a 2D array. Say it is 10x10 and I want a 1D Array of 100 elements... What is the syntax?
oneD = reshape(twoD, (100,1)) or oneD = reshape(twoD, (1,100))
One I guess is the transpose of the other but both seem to be arrays of arrays...
Or
oneD = ravel(twoD)
--
Robert Kern ro*********@gmail.com
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
KraftDiner wrote: I have a 2D array. Say it is 10x10 and I want a 1D Array of 100 elements... What is the syntax?
oneD = reshape(twoD, (100,1)) or oneD = reshape(twoD, (1,100))
One I guess is the transpose of the other but both seem to be arrays of arrays...
help?!
Using pyarray, as mentioned in the previous thread:
#from http://svn.brownspencer.com/pyarray/trunk/ from pyarray import ndlist
source_list = [range(i*10,(i+1)*10) for i in range(10)] source_array = ndlist(source_list) source_array
array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
[20, 21, 22, 23, 24, 25, 26, 27, 28, 29],
[30, 31, 32, 33, 34, 35, 36, 37, 38, 39],
[40, 41, 42, 43, 44, 45, 46, 47, 48, 49],
[50, 51, 52, 53, 54, 55, 56, 57, 58, 59],
[60, 61, 62, 63, 64, 65, 66, 67, 68, 69],
[70, 71, 72, 73, 74, 75, 76, 77, 78, 79],
[80, 81, 82, 83, 84, 85, 86, 87, 88, 89],
[90, 91, 92, 93, 94, 95, 96, 97, 98, 99]]) source_array.flat
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
98, 99]) list(source_array.flat)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
In this case, pyarray.ndlist behaves the same as numpy.array
Michael This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Brian |
last post by:
I'm diddlying with a script, and found some behavior I don't understand.
Take this snippet:
for ($i = 0; $i <= count($m); $i++) {
array_shift($m);
reset($m);
}
|
by: Stormkid |
last post by:
Hi Group I'm trying to figure out a way that I can take two (two
dimensional) arrays and avShed and shed, and subtract the matching elements
in shed from avShed I've pasted the arrays blow from a...
|
by: Kyler Laird |
last post by:
I'm trying to discover if there's an efficient way to determine
if all of the values of a Numeric array are the same. In C, I
would search from the second value, checking each against the
first...
|
by: Stephen Boulet |
last post by:
I have a long list of floats (1613808 elements long). It takes quite a
while to load this into a 7 dimensional Numeric array.
Is there any obvious way to speed this up?
def...
|
by: Faheem Mitha |
last post by:
Dear People,
I have the current modest goal. Given a user defined class, I want to
creata an array of instances of that class.
Consider the following class.
class cell:
def...
|
by: Treetop |
last post by:
I cannot get this array to work. I want to have the game listed until the
day after the event, then come off the list.
function events() {
var today = new Date();
var dayarray=new...
|
by: KraftDiner |
last post by:
I have a list that starts out as a two dimensional list
I convert it to a 1D list by:
b = sum(a, )
any idea how I can take be and convert it back to a 2D list?
|
by: David d'Angers |
last post by:
hi all
i need to do matrix manipulations in c
things like "reshape" of matlab etc
and i'd like some advice for choosing a library
i'm doing development in computer vision
thanks
|
by: knielsen73 |
last post by:
Hi,
I am a python newbie, trying to convert my IDL scripts to python. I am
kind of stuck at the moment. I am reading in a 1-D data file with 2000
data points. I need to put them in a 3-D array...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |