Tagged Questions
76
votes
4answers
14k views
How do you use the ellipsis slicing syntax in Python?
This came up in Hidden features of Python, but I can't see good documentation or examples that explain how the feature works.
69
votes
4answers
12k views
Why NumPy instead of Python lists?
Is it worth my learning NumPy?
I have approximately 100 financial markets series, and I am going to create a cube array of 100x100x100 = 1 million cells. I will be regressing (3-variable) each x with ...
32
votes
5answers
2k views
Fast tensor rotation with NumPy
At the heart of an application (written in Python and using NumPy) I need to rotate a 4th order tensor. Actually, I need to rotate a lot of tensors many times and this is my bottleneck. My naive ...
24
votes
3answers
10k views
How to install python modules without root access?
I'm taking some university classes and have been given an 'instructional account', which is a school account I can ssh into to do work. I want to run my computationally intensive Numpy, matplotlib, ...
17
votes
4answers
5k views
multithreaded blas in python/numpy
I am trying to implement a large number of matrix-matrix multiplications in python. Initially, I assumed that numpy would use automatically my threaded blas libraries since I built it against those ...
13
votes
4answers
16k views
Iterating through a multidimensional array in Python
I have created a multidimensional array in Python like this:
self.cells = np.empty((r,c),dtype=np.object)
Now I want to iterate through all elements of my twodimensional array, and I do not care ...
13
votes
2answers
3k views
What are the differences between Pandas and NumPy+SciPy in Python?
They both seem exceedingly similar and I'm curious as to which package would be more beneficial for financial data analysis.
9
votes
1answer
1k views
NumPy or Pandas: Keeping array type as integer while having a NaN value
Is there a preferred way to keep the data type of a NumPy array fixed as int (or int64 or whatever), while still having an element inside listed as numpy.NaN?
In particular, I am converting an ...
8
votes
3answers
1k views
How do I find out if a numpy array contains integers?
I know there is a simple solution to this but can't seem to find it at the moment.
Given a numpy array, I need to know if the array contains integers.
Checking the dtype per-se is not enough, as ...
7
votes
2answers
3k views
Calculating the area under a curve given a set of coordinates, without knowing the function
I have one list of 100 numbers as height for Y axis, and as length for X axis: 1 to 100 with a constant step of 5. I need to calculate the Area that it is included by the curve of the (x,y) points, ...
6
votes
2answers
3k views
difference between numpy dot() and inner()
What is the difference between
import numpy as np
np.dot(a,b)
and
import numpy as np
np.inner(a,b)
all examples I tried returned the same result. Wikipedia has the same article for both?! In the ...
5
votes
4answers
104 views
Matrix completion in Python
Say I have a matrix:
> import numpy as nap
> a = np.random.random((5,5))
array([[ 0.28164485, 0.76200749, 0.59324211, 0.15201506, 0.74084168],
[ 0.83572213, 0.63735993, ...
5
votes
3answers
4k views
Convert numpy array to tuple
Note: This is asking for the reverse of the usual tuple-to-array conversion.
I have to pass an argument to a (wrapped c++) function as a nested tuple. For example, the following works
X = ...
4
votes
2answers
45 views
How to extract the bits of larger numeric Numpy data types
Numpy has a library function, np.unpackbits, which will unpack a uint8 into a bit vector of length 8. Is there a correspondingly fast way to unpack larger numeric types? E.g. uint16 or uint32. I am ...
3
votes
1answer
249 views
Which is faster, numpy transpose or flip indices?
I have a dynamic programming algorithm (modified Needleman-Wunsch) which requires the same basic calculation twice, but the calculation is done in the orthogonal direction the second time. For ...