column « numpy « Python Data Type Q&A

Home
Python Data Type Q&A
1.array
2.date
3.dictionary
4.Format
5.integer
6.List
7.numpy
8.regex
9.string
10.tuple
Python Data Type Q&A » numpy » column 

1. In Python, how do I join two arrays by key column?    stackoverflow.com

Suppose I have two arrays (after import numpy as np),

a=np.array([['a',1],['b',2]],dtype=object)
and
b=np.array([['b',3],['c',4]],dtype=object)
How do I get:
c=np.array([['a',1,None],['b',2,3],['c',None,4]],dtype=object)
Basically, an join using the first column as key. Thanks

2. numpy: access an array by column    stackoverflow.com

suppose I have:

test = numpy.array([[1, 2], [3, 4], [5, 6]])
test[i] gets me ith line of the array (eg [1, 2]). how can i access the ith column? (eg [1, 3, 5]). ...

3. mask a 2D numpy array based on values in one column    stackoverflow.com

Suppose I have the following numpy array:

a = [[1, 5, 6],
     [2, 4, 1],
     [3, 1, 5]]
I want to mask all the rows ...

4. Swapping columns in a numpy array?    stackoverflow.com

from numpy import *
def swap_columns(my_array, col1, col2):
    temp = my_array[:,col1]
    my_array[:,col1] = my_array[:,col2]
    my_array[:,col2] = temp
Then
swap_columns(data, 0, 1)
Doesn't work. However, calling the ...

5. accumulate numpy array for just one column    stackoverflow.com

I have a NumPy array, i want to accumulate the values of one column, say the 2nd column.

a = np.array([[1,2],[2,4]])
# some kind of accumulate function that accumulates just one column:
np.add.accumulate(a, 2)
a ...

6. Adding a new column to a list of matrixs(arrays)    stackoverflow.com

I have a problem with lists/arrays/matrix at Python. I have a list of matrix (or arrays if it need to be) and i want to add to every single of of them ...

7. How to mask numpy structured array on multiple columns?    stackoverflow.com

I have a numpy structured array with a dtype such as:

A = numpy.empty(10, dtype=([('segment', '<i8'), ('material', '<i8'), ('rxN', '<i8')]))
I know I can create a mask such as:
A[A['segment'] == 42] = ...
Is ...

8. Most efficient way to sum huge 2D NumPy array, grouped by ID column?    stackoverflow.com

I have a massive data array (500k rows) that looks like:

id  value  score
1   20     20
1   10     30
1 ...

9. Composite a numpy array/matrix based on column values and variables?    stackoverflow.com

I just started to play with numpy/scipy a bit and I'm having trouble finding a feature in the documentation and I was wondering if you could help: If I have an array ...

10. How slice Numpy array by column value    stackoverflow.com

I have an array like this numpy array

 dd =[[0.567 2 0.611]
      [0.469 1 0.479]
      [0.220 2 0.269]
    ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.