Category "numpy"

how to fill a Pandas dataframe column with a list containing string values

I have a dataframe with 142 rows. I have created a new column. I want to fill this new column with a list containing strings. my_list = ['abc','def','hig'] df[

Does Pandas, SciPy, or NumPy provide a cumulative standard deviation function?

I have a Pandas series. I need to get sigma_i, which is the standard deviation of a series up to index i. Is there an existing function which efficiently calcul

Why does PyCharm give unresolved reference errors on some Numpy imports?

The following line in PyCharm is flagged by on-the-fly inspection with unresolved reference errors for each import. (They are underlined red.) from numpy impor

numpy random choice in Tensorflow

Is there an equivalent function to numpy random choice in Tensorflow. In numpy we can get an item randomly from the given list with its weights. np.random.c

How to mask image with binary mask?

Suppose I have a greyscale image here: And a binary masked image here: With the same dimensions and shape. How do I generate something like this: Where the v

Python OpenCV - How to save a 5 channel image

I'm using Google Colab with Python 3 and I need to merge 3 images to make a new one with 5 channels, but i get this error: error: OpenCV(4.1.2) /io/opencv/modu

How can I reshape a Pandas DataFrame to show if certain values in a column are present by day?

I'm writing a script to query a database and return a DataFrame, df, that looks like this: cost data_source process_date revenue 0 0.796895

numpy: formal definition of "array_like" objects?

In numpy, the constructors of many objects accept an "array_like" as first argument. Is there a definition of a such object, either as an abstract meta class, o

How to printing numpy array with 3 decimal places? [duplicate]

How can I print numpy array with 3 decimal places? I tried array.round(3) but it keeps printing like this 6.000e-01. Is there an option to mak

Is there a way to make a complex number in NumPy with the accuracy of a Decimal type?

I'm working in Python with NumPy arrays of complex numbers that extend well past the normal floating point limits of NumPy’s default Complex type (numbers

Resize multiple images with OpenCV to square size without padding

My question is simple yet I haven't found any solution on Google, all the answers are for adding padding which in my case I don't want... It's basically resizin

How to construct a ndarray from a numpy array? python

I can't seem to convert it into an ndarray in numpy, i've read http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html but it didn't show me how

something wrong about scipy and numpy, when i import scipy.stats.linregress

when i import scipy.stats.linregress, to do something about ols, there is a typeerror. when i run my code in pycharm, all is ok. there is no error and i can get

Extract subarray between certain value in Python

I have a list of values that are the result of merging many files. I need to pad some of the values. I know that each sub-section begins with the value -1. I am

Creating a Linear Gradient Mask using opencv or

I am trying to stitch images together right now to create panoramas. The approach that I have tried so far was to warp the first image and align the second imag

How to generate a matrix with circle of ones in numpy/scipy

There are some signal generation helper functions in python's scipy, but these are only for 1 dimensional signal. I want to generate a 2-D ideal bandpass filte

Scikit Learn SVC decision_function and predict

I'm trying to understand the relationship between decision_function and predict, which are instance methods of SVC (http://scikit-learn.org/stable/modules/gene

Can numpy bincount work with 2D arrays?

I am seeing behaviour with numpy bincount that I cannot make sense of. I want to bin the values in a 2D array in a row-wise manner and see the behaviour below.

Exception thrown in PyCharm debug mode but not in run mode (seaborn, matplotlib)

I'm using PyCharm 2021.2.3 Community Edition Python interpreter 3.10.0 matplotlib 3.5.0 seaborn 0.11.2 numpy 1.21.4 pandas 1.3.4 PySimpleGUI 4.55.1 When I run t

python(or numpy) equivalent of match in R

Is there any easy way in python to accomplish what the match function does in R? what match in R does is that it returns a vector of the positions of (first) m