Category "numpy"

How to make a vector of matrices in numpy

I would like to create a vector of the same matrix in numpy (so as an array). Let's say the matrix is: w = np.array([[1,2], [3,4], [

Linearregression of two dataframes

I have two dataframes: df = pd.DataFrame([{'A': -4, 'B': -3, 'C': -2, 'D': -1, 'E': 2, 'F': 4, 'G': 8, 'H': 6, 'I': -2}]) df2 looks like this (just a cutout; i

How to adapt emcee to work with odeint numerical solution

I'm trying to constrain the function with the use of MCMC methods (emcee) without the analytical form of this function. I'm using the odeint to obtain the funct

cv2.error: OpenCV(4.5.2) 👎 error: (-5:Bad argument) in function 'cvtColor'

this is my code and I have a problem. What is the solution for it, please? I try to make a screen recorder: import numpy as np import cv2 import pyautogui code

Complex interpolation for Isotopic data

I have another question, is there a package that interpolates precipitation data taking into account mountains and oceans? I have so far used Numpy and Basemap

Remove variables from a recarray by variable name

I need to concatenate 2 rec.arrays (same procedure I do for all other in my work). Problem I have is one of the documents I read for the array, has 2 extra vari

Poor accuarcy score for Semi-Supervised Support Vector machine

I am using a Semi-Supervised approach for Support Vector Machine in Python for the image classification from PASCAL VOC 2007 data. I have tried with the default

Inconsistent indexing of subplots returned by `pandas.DataFrame.plot` when changing plot kind

I know that, this issue is known and was already discussed. But I am encountering a strange behaviour, may be someone has idea why: When I run this: plot = df.p

Numpy where function in python

I have a data frame like this: pd.DataFrame({'Material': ['Steel (16MnCr5)', 'X', 'X', 'X', 'Carbon black', 'Sulfur', 'Copper'], 'Weight': [4, 8, 0, 8, 6, 9, 3

how to do count of particular value of given column corresponding to other column

To count the particular value of given column

How to set space between the axis and the label in matplotlib

My code: #importing required libraries import numpy as np from matplotlib.patches import Polygon import matplotlib.pyplot as plt #plotting data def func(x):

Python numpy np.argmax() using user specific range/axis

I have an array named fft with the length of length (800) and want to get the np.argmax(fft) and get as expected the maximum at position result (420). The data

extract intensity profile along a line from image

ch4-out is the sample imageI have a numpy array that contains some image data (ch4_out). Now, I want to extract intensity profile along a particular line (horiz

How to vectorize such an algorithm in python?

I have four (nx1) dimensional arrays named a, b, c, and F. I want to run this algorithm without any loops. for i in range(n): if a[i] < b[i]: F[i

how to find possible combinations

I have an array of 16 columns and 22 rows. please advice how to find all possible combinations with the following rules: I can't choose more than 1 value per ro

IndexError: invalid index to scalar variable while testing

This is the code used in testing. I have been getting the error shown bellow. Can someone please tell me how to solve it? This is a custom trained model. I have

How to create a 2D numpy array from a block of strings

With list comprehension, I am able to take a 20x20 block of numbers in string format, and convert it to a list of lists of integers. The numbers are seperated b

ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

Importing from pyxdameraulevenshtein gives the following error, I have pyxdameraulevenshtein==1.5.3, pandas==1.1.4 and scikit-learn==0.20.2. Numpy is 1.16.1.

Output doesn't come. Plotting issue [Matlab to python conversion]

This is my Pyhton code. import numpy as np import matplotlib.pyplot as plt n = 3; #% No of image T = 100;

Performance issues when iterating numpy array

I have a 3D array of image such as [ [ [225, 0, 0], [225, 225, 0], ... ], [ [225, 0, 0], [225, 225, 0],