numpy Questions

2

Solved

I have player A and B who both played against different opponents. player opponent days ago A C 1 A C 2 A D 10 A F 100 A F 101 A F 102 A G 1 B C 1 B C 2 B D 10 B F 100 ...
Carricarriage asked 2/8, 2024 at 5:29

4

Solved

(my2022) C:\Users\donhu>pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 Looking in indexes: https://pypi.org/simple, https://download.pytorch.o...
Earthshine asked 24/4, 2022 at 8:18

5

I was trying to install numpy version 1.22.3 on a M1 Macbook with pip3, and pip3 says the package is present, but when I try to import the module, an error gets thrown at me that says Importing the...
Ratable asked 5/4, 2022 at 3:2

3

Solved

Looks like numpy is using deprecated function DataFrame.swapaxes in fromnumeric.py. Anaconda3\lib\site-packages\numpy\core\fromnumeric.py:59: FutureWarning: 'DataFrame.swapaxes' is deprecated and w...
Lavaliere asked 30/11, 2023 at 7:56

4

Solved

I know how to solve A.X = B by least squares using Python: Example: A=[[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,0,0]] B=[1,1,1,1,1] X=numpy.linalg.lstsq(A, B) print X[0] # [ 5.00000000e-01 5....
Agrarian asked 25/11, 2014 at 13:58

2

The following two functions logically do the same thing, but func2, which stores the result in a temporary variable, is slower. def func1(a): return a.astype(np.float64) / 255.0 def func2(a): t...
Puentes asked 27/7, 2024 at 16:26

2

Solved

In this question I asked the community about how scipy.interpolate.splev calculates a spline basis.. My goal was to compute a spline faster then splev by pre-calculating a bspline basis and generat...
Krissy asked 28/8, 2017 at 22:5

4

i am trying to crop out the faces from instagram avatars by first detecting the faces and then resizing the image. i am reading all the images which have been stored in a dataframe and then creatin...
Loutitia asked 13/2, 2018 at 10:25

4

Solved

I have a symmetric matrix represented as a numpy array, like the following example: [[ 1. 0.01735908 0.01628629 0.0183845 0.01678901 0.00990739 0.03326491 0.0167446 ] [ 0.01735908 1. 0.0213712 0....
Plaque asked 23/1, 2014 at 18:7

5

Solved

Lets say I have the following matrix: A = np.array([ [1,2,3], [4,5,6], [7,8,9]]) How can I extract the upper triangle matrix without the diagonal efficiently? The output would be the follow...
Raasch asked 15/11, 2017 at 18:29

3

Solved

I have a symmetric square DataFrame in pandas: a = np.random.rand(3, 3) a = (a + a.T)/2 np.fill_diagonal(a, 1.) a = pd.DataFrame(a) That looks like this: 0 1 2 0 1.000000 0.747064 0.357616 1 0...
Labour asked 11/8, 2017 at 9:13

3

Solved

I have a square matrix A (could be any size) and I want to take the upper triangular part and place those values in an array without the values below the center diagonal (k=0). A = array([[ 4, 0, ...
Lapp asked 17/12, 2013 at 22:4

4

Solved

Suppose I have a matrix that is 100000 x 100 import numpy as np mat = np.random.randint(2, size=(100000,100)) I wish to go through this matrix, and if each row contains entirely either 1 or 0 I...
Buroker asked 25/6, 2019 at 15:49

4

Solved

I have an upper-triangular matrix of np.float64 values, like this: array([[ 1., 2., 3., 4.], [ 0., 5., 6., 7.], [ 0., 0., 8., 9.], [ 0., 0., 0., 10.]]) I would like to convert this into the c...
Marino asked 5/11, 2019 at 19:42

2

I am writing Python script to code for finding probability of Hypergeometric distribution. When I am using hypergeom() function in scipy, it is showing like below: scipy.stats.distributions.rv_fro...
Griffe asked 17/8, 2015 at 9:23

2

A recent immigrant to Python and scientific computing with Python. This is a question to avoid any duplication of code that might already exist. I have a field that is sampled as a function of x a...
Conversion asked 7/12, 2012 at 23:47

2

Solved

I need to sort uint64 arrays of length 1e8-1e9, which is one of the performance bottlenecks in my current project. I have just recently updated numpy v2.0 version, in which the sorting algorithm is...
Celom asked 21/6, 2024 at 17:19

9

Solved

i'm calculating Gini coefficient (similar to: Python - Gini coefficient calculation using Numpy) but i get an odd result. for a uniform distribution sampled from np.random.rand(), the Gini coeffici...
Jewett asked 15/9, 2016 at 13:26

4

Solved

I want to do something similar to what was asked here NumPy array, change the values that are NOT in a list of indices, but not quite the same. Consider a numpy array: > a = np.array([0.2, 5.6...
Debrief asked 30/11, 2016 at 17:29

4

Solved

I understood simple concepts about comma operator in python. For instance, x0, sigma = 0, 0.1 means x0=0, and sigma=0.1. But I obtained a code that has a line that looks like the following. y,...
Cryptology asked 8/8, 2017 at 17:37

4

Solved

I'm looking at a third-party lib that has the following if-test: if isinstance(xx_, numpy.ndarray) and xx_.dtype is numpy.float64 and xx_.flags.contiguous: xx_[:] = ctypes.cast(xx_.ctypes._as_par...
Afterdeck asked 14/11, 2014 at 2:15

4

Solved

I would like to fit a 2D array by an elliptic function: (x / a)² + (y / b)² = 1 ----> (and so get the a and b) And then, be able to replot it on my graph. I found many examples on internet, but n...
Acrid asked 18/12, 2017 at 17:44

3

Solved

I am trying to import ArrayLike doing from numpy.typing import ArrayLike, and I get the error mentioned in the title: ModuleNotFoundError: No module named 'numpy.typing' I know I could simply write...
Cullen asked 16/4, 2021 at 1:10

2

Solved

Let's say I have an array of permutations perm which could look like: perm = np.array([[0, 1, 2], [1, 2, 0], [0, 2, 1], [2, 1, 0]]) If I want to apply it to one axis, I can write something like: v...
Catholic asked 15/7, 2024 at 6:58

8

I used the following command to know the numpy version I am using pip show numpy output shown below --- Name: numpy Version: 1.8.2 Location: /usr/lib/python2.7/dist-packages Requires: Howev...
Fr asked 2/12, 2015 at 19:51

© 2022 - 2025 — McMap. All rights reserved.