Tag: numpy

51 votes
5 answers
1K views
Compute a confidence interval from sample data

I have sample data which I would like to compute a confidence interval for, assuming a normal distribution. I

avatar
Charis
0 1 0 9
asked 07 September, 2021
58 votes
8 answers
1.2K views
Installing SciPy and NumPy using pip

I'm trying to create required libraries in a package I'm distributing. It requires both the SciPy an

avatar
Hilario
0 1 0 9
asked 07 September, 2021
61 votes
10 answers
962 views
Fitting empirical distribution to theoretical ones with Scipy (Python)?

INTRODUCTION: I have a list of more than 30,000 integer values ranging from 0 to 47, inclusive, e.g.[0,0,0,0,.

avatar
Renaldo
0 1 0 9
asked 07 September, 2021
55 votes
8 answers
2.6K views
How to normalize a NumPy array to within a certain range?

After doing some processing on an audio or image array, it needs to be normalized within a range before it can

avatar
Basil
0 1 0 9
asked 07 September, 2021
56 votes
7 answers
1.2K views
How to add a new row to an empty numpy array

Using standard Python arrays, I can do the following: arr = [] arr.append([1,2,3]) arr.append([4,5,6]) # arr

avatar
Dorinda
0 1 0 9
asked 07 September, 2021
43 votes
7 answers
2.6K views
How to do exponential and logarithmic curve fitting in Python? I found only polynomial fitting

I have a set of data and I want to compare which line describes it best (polynomials of different orders, expo

avatar
Luis
0 1 0 9
asked 07 September, 2021
54 votes
17 answers
3.1K views
Calculating Pearson correlation and significance in Python

I am looking for a function that takes as input two lists, and returns the Pearson correlation, and the signif

avatar
Percy
0 1 0 9
asked 07 September, 2021
56 votes
28 answers
1.7K views
Moving average or running mean

Is there a SciPy function or NumPy function or module for Python that calculates the running mean of a 1D arra

avatar
Yolando
0 1 0 9
asked 07 September, 2021
62 votes
10 answers
2.7K views
How to smooth a curve in the right way?

Lets assume we have a dataset which might be given approximately by import numpy as np x = np.linspace(0,2*np

avatar
Bryan
0 1 0 9
asked 07 September, 2021
47 votes
29 answers
1.7K views
Import Error: No module named numpy

I have a very similar question to this question, but still one step behind. I have only one version of Python

avatar
Fabian
0 1 0 9
asked 07 September, 2021
60 votes
8 answers
1.2K views
Relationship between SciPy and NumPy

SciPy appears to provide most (but not all [1]) of NumPy's functions in its own namespace. In other words

avatar
Tuan
0 1 0 9
asked 07 September, 2021
54 votes
5 answers
1.6K views
Using NumPy and Cpython with Jython

I must use a commercial Java library, and would like to do it from Python. Jython is robust and I am fine with

avatar
Nereida
0 1 0 9
asked 07 September, 2021
52 votes
7 answers
1.2K views
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I just discovered a logical bug in my code which was causing all sorts of problems. I was inadvertently doing

avatar
Dwain
0 1 0 9
asked 07 September, 2021
52 votes
8 answers
1.1K views
dropping infinite values from dataframes in pandas?

what is the quickest/simplest way to drop nan and inf/-inf values from a pandas DataFrame without resetting mo

avatar
Scot
0 1 0 9
asked 07 September, 2021
56 votes
7 answers
1.9K views
NumPy array initialization (fill with identical values)

I need to create a NumPy array of length n, each element of which is v. Is there anything better than: a = e

avatar
Chaya
0 1 0 9
asked 07 September, 2021
62 votes
16 answers
1.9K views
Better way to shuffle two numpy arrays in unison

I have two numpy arrays of different shapes, but with the same length (leading dimension). I want to shuffle e

avatar
Wilfredo
0 1 0 9
asked 07 September, 2021
55 votes
16 answers
1.5K views
numpy: most efficient frequency counts for unique values in an array

In numpy / scipy, is there an efficient way to get frequency counts for unique values in an array? Something

avatar
Xavier
0 1 0 9
asked 07 September, 2021
53 votes
10 answers
642 views
How to take column-slices of dataframe in pandas

I load some machine learning data from a CSV file. The first 2 columns are observations and the remaining colu

avatar
Basil
0 1 0 9
asked 07 September, 2021
57 votes
10 answers
599 views
How do I convert a numpy array to (and display) an image?

I have created an array thusly: import numpy as np data = np.zeros( (512,512,3), dtype=np.uint8) data[256,256

avatar
Tana
0 1 0 9
asked 07 September, 2021
57 votes
13 answers
1.8K views
Converting numpy dtypes to native python types

If I have a numpy dtype, how do I automatically convert it to its closest python data type? For example, num

avatar
Lashawna
0 1 0 9
asked 07 September, 2021