Category "numpy"

Change of behavior of a function to compute multiple numpy arrays mean

I have three BGR color values (stored into numpy arrays) and I want to compute their mean value (of each element, as to have a numpy array looking like this : [

pipenv locking for NumPy fails on Python3.9 and pip21.0.1

When I try to install pandas via pipenv I get a bunch of numpy errors after the locking process. When I try to install bs4 via pipenv it works fine, but for som

How to fix the NumPy .dtype 'NoneType' error

I am running the following Python code in PyCharm debug mode. import numpy as np, pandas as pd, numpy.polynomial.chebyshev as chebyshev from pathlib import Path

Problem to integrate a function with multiple array in python

I work on a Python Script and I need to integrate a very long function. The function contains several array and I don't succeed to integrate it. I need to integ

How to perform binomial-coefficient and factorial calculation with more precision?

I was comparing the result of my following python calculation with Mathematica: https://www.wolframalpha.com/input?i=sum+%28500+choose+r+%29%28-1%29%5Er+%2F%28r

iterating different length arrays and replace values

I have a dataframe that looks like this: df = pd.DataFrame({'col1': [[[1,5,3],[0,0,0]], [[1,2,3],[0,0,0], [1,2,3]]]}) # which looks like this: col1 0 [[1

Solve linear Inequalities

I want to solve a system of inequalities A x <= b, namely to visualize the set of solutions of this system. Are there any ways to do this in Python? The solu

why the first example in xtensor can't run?

I install the xtensor by conda conda install -c conda-forge xtensor and I find the position where the xtensor is installed, path_xtensor="/amax/home/user/minic

Trouble computing integral with scipy quad

I'm trying to compute the following definite integral: Integral I want to compute: where rho_ch is and a = 3.66 * 10^(-15) m (in meters) b = 0.54 * 10^(-15) m

Count occurrences within a specific range

I have a data frame that looks like this: Tag 0 skip_1 1 run 2 skip_1 3 run 4 skip_1 5

How do I convert numpy.datetime64('2022-04-20T00:00:00.000000000') to datetime.date(2022, 4, 04)

I have a column df['Date] which is a datetime64[ns] type and after doing the sheets= sorted(df['Date'].unique(), reverse =True) I get a numpy.datetime64('2022-

How can I reduce the artifacts generated during "Thin Plate Spline" interpolation in Python?

At the Top "right", there is the 2D-density plot of the recorded data (actual), fewer in number. On the top-left is the interpolated data (thin-plate), i.e. la

Apache error log -- how to fix "numpy ImportError" or disable it?

I'm running a Django app on Apache with mod_wsgi -- everything seems to be working but the following error has been clogging up my logs, running every 30 mins o

Which TensorFlow version is compatible with NumPy version==1.18?

I need to use the librosa and tensorflow packages for a Neural Network audio classification project. librosa has a dependency on the numba package, which requir

Extracting multiple sets of rows/ columns from a 2D numpy array

I have a 2D numpy array from which I want to extract multiple sets of rows/ columns. # img is 2D array img = np.arange(25).reshape(5,5) array([[ 0, 1, 2, 3,

Create surrogate data in python using fourier transform?

I want to create 10,000 sample (random phase but same power spectra) of my original time series using fourier transform. The method I want to opt is given in fi

x and y must be the same size

Using python I'm trying to plot a sin wave and random distribution, then show where the ratio is greater than or equal to 3. I think I'm 90% of the way there bu

Generating constraints for optimization in scipy using loop

There are lots of constraints which I will use in optimization using scipy; so I need to generate the constraints by loop. Below there's a sample of my constrai

ValueError: Input 0 of layer hiddenL1 is incompatible with the layer: its rank is undefined, but the layer requires a define rank

I am trying to create a sequential keras model with custom weights. The weights come from a row in a numpy array. When running the code I get the error: Value

Blockwise reshape in numpy?

I have a numpy array with columns that are in blocks. I want to transpose the blocks. It's conceptually simple, and I guess one can do it simply, but I dont kno