All Questions
Tagged with python-3.x numpy
10,038
questions
1
vote
0
answers
20
views
pycharm Unresolved attribute reference 'astype' for class 'ndarray'
Q: How can I fix the bug where Pychram warns about numpy.ndarray attributes?
The code runs with no problem, however pycharm keeps giving this warning
Unresolved attribute reference 'astype' for class '...
1
vote
1
answer
31
views
Using multiprocessing Pool with a function that takes a list of arrays
I am trying to write a function to read a large number of files in parallel. The code I have for this goes like:
import numpy as np
from multiprocessing import Pool
from functools import partial
def ...
0
votes
0
answers
37
views
Vectorization of power law fitting
I am moving a code base to run using PyTorch tensor on GPU. For loops are terrible on GPU especially for small-sized data. I am trying to vectorize the function below, i.e. to have no for loops.
I ...
-3
votes
0
answers
20
views
how can I compute the striking force of a football player using python [closed]
in a football match between England and Spain Julius Fueke needs a decisive goal, write a Python program that can compute the striking force of each of the players
i tried using the import numpy but ...
2
votes
0
answers
278
views
ModuleNotFoundError: No module named 'numpy._core'
I am trying to load a .npy file created on my local PC with np.save() in google colaboratory. However, when I try to open it on Google Colab with np.load() I get this error: ModuleNotFoundError: No ...
0
votes
1
answer
33
views
Why are my dimensions different when using OpenAi embeddings in Python?
I have a single Python function that I am using the embed JSON objects are different lengths. The issue I am having is that, somehow, the dimensions are different when comparing the vectors and I ...
1
vote
1
answer
57
views
In Python with numpy, how to get uniformly distributed random floats between 0 and a natural x, including both?
In Python with numpy, for a given natural number x, we'd like to get an array (say, 20×2 or whichever shape you wish) of uniformly distributed floats in the interval [0,x]. Notice that the interval is ...
0
votes
1
answer
92
views
How to make python code fast for minimization?
The following code for minimization of a mechanical system works with no error.
However, it is slow and to me there are unnecessary steps or loops that make it heavy!
Would you make comment, and ...
13
votes
1
answer
15k
views
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
MRE
pip install pandas==2.1.1 numpy==2.0.0
Python 3.10 on Google Colab
Output
Collecting pandas==2.1.1
Downloading pandas-2.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.3 MB)
...
0
votes
0
answers
24
views
How does catboost handle np.inf values during training?
I want to know how how catboost handles np.inf values during training? Are they ignored completely or are they treated as a separate value/category?
Can training a model on data that contains np.inf ...
1
vote
2
answers
8k
views
A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.0
I installed numpy 2.0.0
pip install numpy==2.0.0
import numpy as np
np.__version__
#2.0.0
then I installed:
pip install opencv-python
Requirement already satisfied: opencv-python in /usr/local/lib/...
1
vote
1
answer
39
views
Select multiple columns from array, multiple times
Hi I have the following setup:
from scipy
def _bootstrap_resample(sample, n_resamples=None, random_state=None):
"""Bootstrap resample the sample."""
n = sample....
0
votes
0
answers
16
views
Multirow subplots with numpy arrays, AttributeError: 'numpy.ndarray' object has no attribute 'hist' [duplicate]
I've been attempting to create a 2-by-2 grid of plots using matplotlib. My data are numpy arrays, and I am trying to create histograms of the data. However, when I format subplots to output two rows, ...
1
vote
1
answer
329
views
module 'numpy' has no attribute 'bool'
Newer version of numpy doesn't allow me to use pandas.
Importing pandas into my code gives me the following error:
---------------------------------------------------------------------------
...
-1
votes
1
answer
39
views
Pytorch - sending dataset to cuda breaks the dataloader iterator - TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu()
I am trying to speed up my pytorch training by following the advice from here:
https://discuss.pytorch.org/t/cpu-faster-than-gpu/25343/12
So now, I am sending my trainingdata.data and .targets to cuda ...