How add a column to a 2d array/matrix in numarray???
The unelegant way I found was to:
1. Create a new array with an extra column (e.g. using 'zeros' function).
2. Copy original array into new array.
3. Copy new column into last column.
Is there a slicker way to do this?
Chris 4 2663
In article <bf**************************@posting.google.com >, se******@spawar.navy.mil (Christian Seberino) wrote: How add a column to a 2d array/matrix in numarray???
The unelegant way I found was to:
1. Create a new array with an extra column (e.g. using 'zeros' function). 2. Copy original array into new array. 3. Copy new column into last column.
Is there a slicker way to do this?
Try numarray.resize
-- Russell
Thanks for the reply. I appreciate all the help I can get. Your suggestion
of using resize is excellent for adding *rows* but does not seem
right for *columns*. Here is an example: a
array([[ 0, 1, 2, 3, 4, 5],
[ 6, 7, 8, 9, 10, 11],
[12, 13, 14, 15, 16, 17]])
a.resize((4,6)) a
array([[ 0, 1, 2, 3, 4, 5],
[ 6, 7, 8, 9, 10, 11],
[12, 13, 14, 15, 16, 17],
[ 0, 1, 2, 3, 4, 5]])
a.resize((4,7)) a
array([[ 0, 1, 2, 3, 4, 5, 6],
[ 7, 8, 9, 10, 11, 12, 13],
[14, 15, 16, 17, 0, 1, 2],
[ 3, 4, 5, 0, 1, 2, 3]])
Do you see how adding an extra row left old rows intact but
adding an extra column messes up old columns? (i.e.
data in (1,1) position is not the same after adding a column)
Chris
"Russell E. Owen" <no@spam.invalid> wrote in message news:<c6**********@nntp6.u.washington.edu>... In article <bf**************************@posting.google.com >, se******@spawar.navy.mil (Christian Seberino) wrote:
How add a column to a 2d array/matrix in numarray???
The unelegant way I found was to:
1. Create a new array with an extra column (e.g. using 'zeros' function). 2. Copy original array into new array. 3. Copy new column into last column.
Is there a slicker way to do this?
Try numarray.resize
-- Russell
At some point, se******@spawar.navy.mil (Christian Seberino) wrote: Thanks for the reply. I appreciate all the help I can get. Your suggestion of using resize is excellent for adding *rows* but does not seem right for *columns*.
If rows works, you could do transpose/resize/transpose.
--
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
David
Thanks. That was pretty clever methinks.
Chris
co**********@physics.mcmaster.ca (David M. Cooke) wrote in message news:<87************@arbutus.physics.mcmaster.ca>. .. At some point, se******@spawar.navy.mil (Christian Seberino) wrote:
Thanks for the reply. I appreciate all the help I can get. Your suggestion of using resize is excellent for adding *rows* but does not seem right for *columns*.
If rows works, you could do transpose/resize/transpose. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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: Curzio Basso |
last post by:
Hi all,
I was wondering what is the best way to compute the mean vector of a
matrix. Currently I'm doing this:
>>> data.shape
(117027, 8)
>>> mean = (numarray.add.reduce(data,...
|
by: Chris P. |
last post by:
Hi. I have a very simple task to perform and I'm having a hard time
doing it.
Given an array called 'x' (created using the numarray library), is
there a single command that rounds each of its...
|
by: Zhang Le |
last post by:
Hi,
I did a small benchmark of matrix-vector multiply operation using
Numeric module. I'm a bit suprised to find matrix*col-vector is much
faster than row-vector*matrix. I wonder whether other...
|
by: Jeff K |
last post by:
Can you pass an int array by reference to a function and modify
selective elements?
Here is my code:
#include <stdio.h>
#define COLUMNSIZE 30
#define ASIZE 5...
|
by: Anthony Liu |
last post by:
I am talking about the 'take' method of numarray.
See here for more info:
http://stsdas.stsci.edu/numarray/Doc/node33.html
If I initialize a matrix 'mymatrix' by zeros((3,3),...
|
by: Anthony Liu |
last post by:
I am using numarray.
Suppose I have
>>> p = array(range(25), shape=(5,5))
>>> p
array(,
,
,
,
|
by: =?iso-8859-1?B?TWF0dGlhcyBCcuRuZHN0cvZt?= |
last post by:
Hello!
I'm trying to find what package I should use if I want to:
1. Create 3d vectors.
2. Normalize those vectors.
3. Create a 3x3 rotation matrix from a unit 3-d vector and an angle in...
|
by: Bas |
last post by:
On Sep 22, 10:02 am, Al Kabaila <akaba...@pcug.org.auwrote:
That argument might have been valid 3 years ago, but as already said
by others, Numeric and Numarray are deprecated. Numpy should be the...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |