115,202 questions
Score of 0
1 answer
133 views
Making a bar chart with varying values along the y-axis
I'm trying to make a bar chart showing pinned/unpinned vortices depending on tilt. Because of this, I want each bar to represent one vortex, and the y-axis to be the tilt. Currently I have this code, ...
Score of -11
0 answers
364 views
Why colors are not changing [closed]
why i cannot see colors changes?
is this problem in matplotlib ?
i try to change it PIL.Image but same problem
l_path = ".png"
img = imageio.imread(l_path)
#plt.imshow(img, cmap="gray&...
Score of -5
1 answer
511 views
How do I compute operating thresholds for FAR=0% when evaluating biometric match scores in Python/MATLAB? [closed]
I am evaluating a biometric verification system using standard similarity match scores for genuine and impostor comparison distributions.
I need to compute the operational decision threshold ...
Score of -4
3 answers
455 views
Can I broadcast with numpy character find
I have an array of potential substrings and an array of full strings. I'd like to know which elements of the potential substrings are indeed found as substrings in the full array.
import numpy as np
...
Score of -6
0 answers
90 views
How to sum elements in a 2d array and then find max/highest value? [duplicate]
This is my dataset:
data_usage = np.array([
[1.2, 0.8, 1.5, 2.0, 1.1, 3.5, 2.8], # Student A
[2.0, 1.9, 2.2, 1.8, 2.5, 4.0, 3.6], # Student B
[0.5, 0.6, 0.4, 0.7, 0.5, 1.2, 1.0], # ...
Score of 3
2 answers
215 views
How to compute a gradient column-wise in a pandas DataFrame using the index as an input?
I'd like to compute the gradient of a DataFrame, for which I can gather that the best method is to use .apply(), e.g:
d = pd.DataFrame([[1,2,3],[4,5,6],[7,8,9]])
g = d.apply(np.gradient)
print(g)
...
Score of 2
1 answer
171 views
How can I make numpy arrays the same shape before doing conditional computations?
Let's say I have a conditional calculation like this
import numpy as np
def foo(a, b, c):
if a <= 0 or c == 0:
return foo_special(a, b, c)
return foo_normal(a, b, c)
def ...
Score of 1
2 answers
197 views
Create a new column in pandas conditionally based on two other columns that may have overlapping values
In a dataset that contains X and Y coordinates, I want to assign a value in a new column based on the (X,Y) pair in a given row. Imagine a data set that contains the red points shown in the image ...
Score of 1
2 answers
190 views
Working with huge uint8 array without sufficient memory
I am working with huge matrix of small numbers using numpy and getting the following error:
MemoryError: Unable to allocate 9.72 TiB for an array with shape (3268760, 3268760) )data type uint8"
...
Score of 2
2 answers
319 views
Trying to Change A Pixel in Python
I'm trying to change a pixel to red. However, when I run the code, the pixel remains unedited. Can you help?
import cv2 as cv
import os
import matplotlib.pyplot as plt
def readAndWriteImage():
...
Score of 2
1 answer
201 views
Check if matrix contains only specific values in numpy
I have large matrices that contain both real numbers and nan. I want to find the most efficient way to determine if a matrix contains only zeros and/or nan entries. If it does, the code should return ...
Score of 2
0 answers
376 views
Why do C- and Fortran-ordered NumPy arrays show the same L1 cache-miss percentage when formatting a row?
Consider
import numpy as np
N = 2000
a = np.ones((N, 5*N), dtype=np.float64, order="C")
for _ in range(1000):
x = np.array2string(a[0], threshold=np.inf)
and
import numpy as np
N = ...
Score of 3
1 answer
161 views
Full string not added to dictionary in loop [duplicate]
I am running into an issue where my dictionary is not picking up full strings attached to variables, but instead just the first letter.
import numpy as np
import random
trials = 5
d = {'trial': np....
Score of 4
2 answers
207 views
How can I boxplot values that wrap around using matplotlib?
I want to show the distribution of angle estimations using a boxplot. The problem is that angles wrap around (I chose +-180° as the wrapping point, but the same applies to 0/360°).
Matplotlibs boxplot ...
Score of -2
0 answers
175 views
How do I plot this function for all values of the numpy array?
I want some straightforward way to model a for all values of the array like in a for loop. the only way I found was using filtered arrays which is very very tedious.
This function takes a number turns ...