2
votes
2answers
42 views
using list operator “in” with floating point values
I have a list with floats, each number with 3 decimals (eg. 474.259). If I verify the number in the list like this:
if 474.259 in list_sample:
print "something!"
Then the message is shown, but ...
2
votes
2answers
36 views
numpy array indexing says out of range
I think I am doing something wrong in the last line of the code for array indexing. I want the output for p to be like this-
array([[ 0, 0, 0],
[ 0, 0, 0],
[44, 0, 0],
...
0
votes
0answers
18 views
Create and fit a Multiplicative linear regression using Python/Sklearn
I'm using Python 2.7 and Scikit-learn to fit a dataset using multiplicate linear regression, where the different terms are multiplied together instead of added together like in ...
-1
votes
1answer
27 views
Plotting a Pandas DataSeries.GroupBy
I am new to python and pandas, and have the following DataFrame.
How can I plot the DataFrame where each ModelID is a separate plot, saledate is the x-axis and MeanToDate is the y-axis?
Attempt
...
1
vote
1answer
34 views
Something wrong with my fft() in python
I have a function I am supposed to plot the amplitude spectrum of between 10MHz and 11.4MHz. This is the function: cos(6.72*(10**7*t) + 3.2*sin(5*(10**5*t))) I know what the plot is supposed to ...
0
votes
2answers
53 views
Python simple nested for loops
I am trying a simple nested for loop in python to scan a threshold-ed image to detect the white pixels and store their location. The problem is that although the array it is reading from is only ...
2
votes
3answers
50 views
Zero padding multiple values in Python
OKi finally I know how really nice add zero between values in array using numpy:
import numpy as np
arr = np.arange(1,7) # array([1, 2, 3, 4, 5, 6])
np.insert(arr, slice(1,None,2), 0) ...
2
votes
0answers
19 views
Share a numpy array in gunicorn processes
I have a big numpy array that is stored in redis. This array acts as an index. I want to serve filtered result over http from a flask app running on gunicorn and I want all the workers spawned by ...
2
votes
1answer
31 views
Iterate over array of arrays with scipy.weave.inline
I have a numpy.ndarray of dtype object containing exclusively other arrays of different length. I have C code, that does some computations with the nested arrays, but I'm not sure how to grab the ...
3
votes
1answer
56 views
Generate an array of random values from a created function to be plotted
I have a function:
f = x**0.5*numpy.exp(-x/150)
I used numpy and matplot.lib to generate a plot of f as a function of x with x:
x = np.linspace(0.0,1000.0, num=10.0)
I am wondering how do I ...
2
votes
2answers
47 views
Pandas error: 'DataFrame' object has no attribute 'loc'
I am new to pandas and is trying the Pandas 10 minute tutorial with pandas version 0.10.1. However when I do the following, I get the error as shown below. print df works fine.
Why is .loc not ...
0
votes
2answers
22 views
Installing numpy RPM with older Python version
I'm trying to install numpy 1.7 via an RPM on an older Linux machine with Python 2.4. The numpy release notes and the RPM page say it is supposed to be compatible with 2.4 (or <= 2.7), but when I ...
2
votes
4answers
47 views
making multi-dimensional nulls or ones from numpy array
I want to create an array filled with ones or zeros based on this array
testArray = np.array([7,5,3])
so the final result should look like
[[1,1,1,1,1,1,1],
[1,1,1,1,1],
[1,1,1]]
-1
votes
0answers
60 views
Matlab to Python Code
I have piece of code in matlab:
Tf=eye(2);
Tb=eye(2);
Tt=eye(2);
n=250;
f=zeros(2,n);
for i=1:n
f(:,i)=Tf*f(:,i-1);
end
I tried to change it to Python code:
Tf=eye(2)
n=250
...
0
votes
1answer
29 views
Bandpass filter not respecting cutoff
I'm using this filter in python:
def bandpass_firwin(ntaps, lowcut, highcut, fs, window='hamming'):
nyq = 0.5 * fs
taps = firwin(ntaps, [lowcut, highcut], nyq=nyq, pass_zero=False,
...