Most voted "numpy" questions
Numpy is an extension of scientific and numerical computing to the Python programming language.
Learn more…167 questions
Sort by count of
-
0
votes1
answer61
viewsAdd values from a column that are duplicated using groupby as python criteria
I have a data frame that needs to be removed duplicates and later from the previous dataframe I need to add a specific column. Actually I have 5 DF, 4 have already worked, but one because it…
-
0
votes1
answer22
viewsIF no pandas returning The Truth value of a Series is ambiguous. Use a.Empty, a.bool(), a.item(), a.any() or a.all()
I have a DS with two columns, one with a month from 1 to 12, and another with a year from 2015 to 2021, and I’m trying to create a column called Fiscal Year. I am creating a function so that when…
-
-1
votes1
answer37
viewsDoes anyone know how to use an array variable to access a position in a numpy array?
I have A=np.array([[1,2],3]) and I want to use [0,1] to make A[0,1] being [0,1] a variable. I would get 2. Somebody knows how to do this?
-
-1
votes1
answer42
viewsMathematical operation with CSV files
Hello! imported a. csv file with some columns and I would like to do calculations with this data, but I don’t know how to do this. Example as it would be in excel:…
-
-1
votes1
answer54
viewsPerform the reshape of different arrays
Hello! Follow down my doubt: array_a = [1,2,3] array_b = [1,2,3] array_c = [1,2,3] I’d like them to look like this: array_reshaped = [[1, 1, 1], [2, 2, 2], [3, 3, 3]] Could I perform this operation…
-
-1
votes1
answer379
viewsI want to convert Timedelta to float
I have a Dataframe in which one of the columns is the time interval in days between the search from one row to another, the data of this column are in the Timedelta form, as in the example:…
-
-1
votes1
answer67
viewsreplace in numpy array
I have a phrase dataset and how do I use a replace in the numpy array EX x = array(['mais uma vez, o Sr. Costner arrumou um filme por muito mais tempo do que o necessário desse filme.])…
-
-1
votes1
answer74
viewsHow to ask the user to create an np.array vector?
I would like to know HOW is it possible to write a program that reads an array numpy vector np.array([]) user-created. In lists, for example, we do: n = int(input("Determine o número elementos da…
-
-1
votes1
answer37
viewsNumber of elements in ndarray vector
I have the following function to count how many "player" appear in the array estado[i], which is a line of a matrix: for i in range (0, len(estado)): if (estado[i].count(jogador) == len(estado)):…
-
-1
votes2
answers96
viewsPython loop requesting data reentry
I have a problem in my Python code, it is giving loop. Every time I have to insert the list again to show the results. Could someone help me? Follows the code: import numpy as np import pandas as pd…
-
-1
votes1
answer80
viewsMerge array to stay 2 columns
I am with 2 separate array of 1 x 1000 and would like to stay with a single of 2 x 1000. r = array([0.56155503, 0.98218785, 0.95613911, 0.98307298, 0.55173653, 1.04626122, 1.01631092, 1.03858722,…
-
-2
votes1
answer932
viewsHow to measure each individual element in a matrix
Hello, I have the following matrix: matriz = np.array([ [5, 5, 5], [5, 5, 5], [10, 10, 10] ]) and accurate the result with an array of their respective medias, thus: [6.66, 6.66, 6.66] Grateful…
-
-2
votes1
answer792
viewsHow to compare python array in an array list and return the same or nearest array
I would like to know how I can enter with a vector and search in a list of vectors which has more equal or similar values using Python. Example: I have the following vector: search =…
-
-2
votes1
answer108
viewsPrint np.array, formatting
Full class: class Tupla: def __init__(self, keys, palavras): self.keys = list(keys) self.palavras = list(palavras) self.op = dict(zip(self.keys, self.palavras)) def __getitem__(self, key): return…
-
-2
votes1
answer32
viewsHow to use 2-d numpy array with interactive panel floatslider for a python image Plot?
Using holloviews and panel. How to create a function that takes as arguments an np.array (2d, an array) and a "value cut". Return the 2d array plotted as image? Being what the argument "value cut"…
-
-2
votes1
answer495
viewsAttributeerror: 'numpy.ndarray' Object has no attribute 'append'
The program below serves to calculate two matrices (w1 and w2) and, from them, calculate an f rmula (called transmission matrix) and after that take the results of this matrix and trace the…
-
-4
votes1
answer27
viewsHow can I check if there are equal numbers in the same column or row in a numpy matrix?
from random import sample import numpy as np a = sample(range(1, 5), 4) b = sample(range(1, 5), 4) c = sample(range(1, 5), 4) d = sample(range(1, 5), 4) jogo = np.array([[a[0], a[1], b[1], b[2]],…