Ask Question

NumPy is an extension of the Python language that adds support to large multidimensional arrays and matrixes, along with a large library of high-level mathematical functions for operations with these arrays.

102,999 questions 1

0votes0answers9views

Function that uses while can't be evaluated on arrays

When using the numpy module on python I'm used to define functions and then apply them on arrays. For example import numpy as np def function(x): return x+1 sample = function(np.random.uniform(0, ... user avatar Esteban Gutiérrez

  • 101
0votes0answers11views

Create a new column based on condition from a column in another dataset

I have a weird pandas problem I am not sure how to begin. Here are examples of my two datasets: df1: This dataset has a yearly metric per state. Metric Year State 8 1996 AL 6 ... user avatar user2813606

  • 513
1vote0answers25views

Why are numpy arrays of zero length useful?

For example: x = np.array([[[1],[2],[3]], [[4],[5],[6]]]) c = x[1:1,:,:] print(c.shape) print(c + 3) which gives (0, 3, 1) [] It seems that an array of zero length is a black hole, which absorbs all ... user avatar Youjun Hu

  • 605
0votes0answers8views

numpy and python header file location

I am trying to use matplotlib.cpp. I have #include <Python/Python.h> in order to access my Python.h header file at the location /Library/Developer/CommandLineTools/Library/Frameworks/Python3.... user avatar destroyer806

  • 3
-1votes3answers21views

Calculate the prorata weight of a list of numbers (including negative) in Python

I am looking for a way to distribute a positive number proportionally to a list of numbers based on their value (higher gets more). Think of it as distributing a fixed bonus amount based on everyone's ... user avatar DOt dot

  • 1
0votes0answers24views

How can I run this 4 processes at the same time in python? I am not very familiar with multiprocessing

p1 = Conv should generate random numbers. p2 = log This process reads the measured values from Conv and writes them to a local file. p3 = stat This process reads the measured values from Conv and ... user avatar Guts0032

  • 1
0votes1answer20views

appending multiple data frame rows into a list or array

I have this loop that gets every combination from every row in a dataset, and create sub datasets. df NAME VALUE1 VALUE2 0 Alpha 100 A1 1 Alpha 100 A1 2 Alpha 200 A2 ... user avatar Owen Osagiede

  • 51
0votes2answers25views

Replacing elements in ndarray based on condition

I have bi-dimensional array, like that: f_vars = np.array([[0,4], [0,2], [3,-1], [3,4], [1,-1]]) I am trying to replace ... user avatar Petar Andreev

  • 3
0votes0answers18views

more efficient way to cut through 3D matrix along all the plains in numpy

I am trying to cut a 3D array along all it's plains. To capture 2D arrays along all the axes of the 3D array, this will create 13 2D arrays. I was wondering if there is a way to do this with axis and ... user avatar user2315546

  • 1
0votes0answers11views

Looping through a subplot and plotting data [duplicate]

I have tried to create a 4 by 3 scatterplot subplot using a for loop but it only plot some of the axis.my code looks like this so far: import matplotlib.pyplot as plt from sklearn.datasets import ... user avatar Pitso Tladi

  • 1
0votes0answers22views

Trying to update Matplotlib annotations every frame

I try to update the Matplotlib annotations (FPS and frametime) of the output in each new frame. To represent the same values, which are used simultaneously by the line of the graph. After many many ... user avatar HerrTiSo

  • 1
-1votes0answers17views

Why is np.random.multinomial not random with mxnet.np?

import random from mxnet import np, npx npx.set_np() fair_probs = [1.0 / 6] * 6 np.random.multinomial(1, fair_probs) array([0, 0, 0, 0, 0, 1], dtype=int64)#result np.random.multinomial(1, fair_probs)... user avatar kaikaix

  • 1
0votes0answers10views

Finding common values from different csv [duplicate]

I have two csv files (flat and bias) image. I have to check if the first column data of flat is equal to bias or not. If they are common, I want to subtract the second column value of bias from flat. ... user avatar Pritam Das

  • 1
-1votes0answers18views

How do I combine two numpy arrays, one with an extra axis, and use np.apply_along_axis to the combined array?

I have two numpy arrays, A1 with shape (m,n) and A2 with shape (m,n,p). Thus, for i in range(p), A2[...,i] has the same shape as A1. I need to stack each A2[...,i] with A1 and apply a function to ... user avatar user5699217

  • 89
1vote4answers42views

Pivot values in specific order

I have a dataframe where I would like to pivot my data to fit a specific format, making sure the dates are consecutive. Data ID Q122_c_en Q122con_s Q222_c_en Q222con_s Q322_c_en Q322con_s ... user avatar Lynn

  • 3,358

153050per page

1 2 3 4 56867