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
-
15
votes3
answers1932
viewsIs there a more efficient way to create an array from another array dynamically, filtering the contents of the first one?
I have an array of values that can include several numpy.Nan: import numpy as np a = np.array ( [1, 2, np.nan, 4] ) And I want to iterate over your items to create a new array without np.Nan. The…
-
9
votes7
answers7922
viewsConvert an array of floats to integer
Suppose the following: import numpy as np a = np.array ( [1.1, 2.2, 3.3] ) How to convert this array to int without having to iterate each element or using another array? Why do: b = int(a) Gives an…
-
7
votes1
answer638
viewsRecovering list values from python lists
I have tried several things and I still can not grasp what the problem of my code, is a simple code. With numpy i place txt values in the array of arrays and want to make some copies to two other…
-
7
votes1
answer827
viewsCopy a numpy.array without modifying the original
Given a numpy.array as the next: r = np.arange(36) r.resize(6, 6) Which results in: array([[ 0, 1, 2, 3, 4, 5], [ 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23], [24, 25,…
-
6
votes1
answer120
viewsnumpy.diagonal returning read-only copy even in version 1.10
I’m doing a program in Python where I need to change the values diagonally from an array. The following chunk of code should be sufficient to understand the general idea (it changes to 2 the value…
-
5
votes2
answers23393
viewsHow to install numpy and other modules?
I need help installing numpy. I tried to install pygame using Pip but it didn’t work and I was confused on how to install modules or Packages. Use python 3.5.0 in Windows 10 pro
-
4
votes1
answer202
viewsImplement a blink counter in the face detection
As q do to display the amount of flashes of people detected at the time. The code below detects face with Haar Cascade, where it displays a face counter. from __future__ import print_function…
-
3
votes2
answers2354
viewsConcatenate arrays using numpy module
One question, for the solution of linear systems: how to concatenate an array (matrix) A, an array (column vector) b, so that one has the "augmented" matrix of the system, A~ = [A b], using numpy?…
-
3
votes1
answer2149
viewsWhat is the difference between type and dtype?
Based on a previous question, vi that it is possible to identify a variable using type. For example: print(type(3.1415).__name__) #retorno >> float Doing some research, I saw that there is…
-
3
votes1
answer447
viewsImport CSV to Pandas database without converting string to tuple
I upload a CSV file with more than 3 million lines and about 770 Mb, I use pandas and need to convert a column that is in string format. Below the column 'lbBins', which when reading from CSV came…
-
3
votes2
answers434
viewsHow to create a counter in face detection?
As you can see in the code below, it only detects the faces with Haar Cascade, I would like to know how to display on the webcam the amount of people detected at the time. from __future__ import…
-
3
votes1
answer2195
viewsHow does the "argmin()" and "argmax()" function of Numpy work?
Could someone explain to me how the function works argmin() and argmax() of Numpy in a simple and didactic way?
-
3
votes2
answers275
viewsHow to write a program that fills a 10-position vector with random integers between 0 and 20?
How do I create a vector v of 10 random elements in which each element is one whole between 0 and 20? I tried to use the function np.random.random((1,10)), but the output was a vector of decimal…
-
3
votes3
answers529
viewsProduct between scalar and array
I have a vector: a = [0.4850045, 0.45512111] and a vector of an element: b = [-0.03116616] I’m trying to multiply the vector content b, that is to say, b[0], by vector a, but instead of getting :…
-
3
votes0
answers153
viewsMatch of the contours
I created the program below, to make the correction of tests. https://gist.github.com/andreemidio/d2cdf3d301fd8df1677e9a315ff845f0 I was able to outline, identify the fillers, I need to match the…
-
3
votes1
answer207
viewsHow to plot a graph in python using a file containing numpy arrays?
Good afternoon! I am creating a python program that plots the graph of the quadratic function (y=x**2), however, you need to put the data of x and y in a file and plot the graph by extracting the…
-
3
votes2
answers402
viewsChanging lines of an array - Python Pandas
I have an array and need to change the order of the lines. array([[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]]) I need it like this: array([[…
-
3
votes1
answer158
viewsFind differences between arrays, with probability of variation
Good afternoon guys, I’m reading about the numpy library setdiff1d function (https://docs.scipy.org/doc/numpy/reference/generated/numpy.setdiff1d.html). It basically serves to express the different…
-
3
votes2
answers301
viewspython np.Where with two conditions
Hello, I have the following dataframe: import pandas as pd import numpy as np x = pd.DataFrame({'A': [1,2,3,0], 'B': [5,0,0,1]}) What I want is to create a column’D', which is True if the two…
-
3
votes2
answers639
viewsGenerate random numbers in 2d numpy array without repeating Python
Good afternoon, I’m trying to generate a 2d numpy array without repeating numbers. My code: TAMANHO = 4 tabela= np.zeros((TAMANHO, TAMANHO), dtype = int) tabela[:, 0] = np.random.randint(1, 170,…
-
3
votes2
answers58
viewsHow does the numpy Prod method work?
I’ve always used the method np.prod as a production operator. So if I want to know the factorial of 5, for example, I simply do: import numpy as np np.prod([5,4,3,2,1]) 120 It turns out I was…
-
2
votes1
answer6338
viewsPython matrix manipulation with numpy module
How do I exchange lines of matrices, using numpy? I need this to implement the Gauss-Jordan method of linear systems solution with partial pivoting.
-
2
votes2
answers1631
viewsHow to install Numpy via PIP windows 7 64 bit
Good afternoon as I do to install Numpy via Pip. I downloaded Python 2.7.13 and do not know how to install via Pip.
-
2
votes1
answer988
viewsPython - invalid literal for float()
I have an array that looks like this training_set = [['03/11/2017' '16,94'] ['01/11/2017' '16,90'] ['31/10/2017' '16,77'] ... However, I cannot manipulate the numbers because they are in the form of…
-
2
votes1
answer959
viewsPython Interpolate Txt
Good night, I recently started the program in python because of an elective I have at university, but my knowledge is still minimal. My teacher gave a job to do where I should create a code that…
-
2
votes1
answer1199
viewsProblem with arrays in Python 3.6
I started a small course on deep learning with Python, but I ended up having a problem with arrays... I usually take the code from the class and modify it a lot before creating an original, but this…
-
2
votes1
answer505
viewsTransformed problem of Fourier
I’m having a problem using the fft function of numpy. When rotating it, the answer is giving different from the Fourier transform that I implemented manually and by the tests I did the manual seems…
-
2
votes1
answer3034
viewsHow to customize the x-axis of a graph with two y-axes, for text?
I would like to know how I change my x-axis from a graph with two y-axes, because I want to give the x-axis names of Brazilian states. numpy_matrix = df.as_matrix() x = numpy_matrix[0:,0] y1 =…
-
2
votes1
answer87
viewsConsistency in Python results
Hello, I’m studying python code and I came across this line: np.random.seed(0) where it says consistency of results. I searched, but I still can’t understand the function of this command. Could…
-
2
votes1
answer1375
viewsScalar product
Objective: To make a neuron using the load of weights and inputs from an xlsx The scalar product has been calculated in several ways as exercise, but when I try to use the dot gives error. the…
-
2
votes1
answer2222
views -
2
votes1
answer82
viewsWhat is the bincount method of numpy for/what?
I read the documentation but I don’t understand what it does: print(np.bincount(np.array([0, 1, 1, 1, 2, 3, 7]))) The exit is: [1 3 1 1 0 0 0 1]…
-
2
votes1
answer89
viewsBase conversion
In a college job we were required to simulate the functioning of a RAM memory. The user can read or write in the cells of this memory or all Zera, and each one stores 8 bits. That part’s already…
-
2
votes1
answer217
viewsCalculating numerical integrals from numpy arrays
I have the triple integral of the figure. I used the documentation of the scipy to solve her. Now I want to exchange the values of the upper limits of x, y and z, which in this problem are the…
-
2
votes1
answer50
viewsIndex 3D arrays with Numpy
I have an array in three dimensions (x, y and z) and an address vector. This vector has a size equal to the x dimension of the array, and its objective is for each x to point a y bringing their…
-
2
votes1
answer141
viewsPerform data counting based on grouping 2 or more columns in a Pandas.Dataframe
I want to find in this Dataframe, the 3 best user_id for Nome prova. That is, those who have the highest number of values 1 in the correct column ( such column is composed of values 0 and 1 ): Nome…
-
2
votes2
answers328
viewsSelect column numpy no for
I’ll be very brief. I’m just wondering how to put in for when the values of the first column of the matrix is less than zero, the values of the second column will be a. from scipy import stats from…
-
2
votes2
answers41
viewsHow to get the X coordinate if the Y condition is met with Numpy?
I created a function that gives me this array as output in which each line corresponds to a point : array([[0.57946528, 2. ], [0.35226154, 0. ], [0.26088698, 0. ], [0.56560726, 1. ], [0.41680759, 1.…
-
2
votes1
answer37
viewsIs there a way to assign values to symbolic variables after deriving them using sympy?
Hello, I need to write a code that derives a user-informed function and then assign values to variables to perform the calculation. The problem is that it is necessary for the variables to be…
python numpy calculus ipython-notebook sympyasked 3 years, 9 months ago Leonardo Barbosa Brandão 23 -
1
votes2
answers1175
viewsPython Numpy library
Like installing a library in python, using Windows 7. I try to download the Numpy and appears at the prompt: libraries f77blas,cblas,atlas not found in C:\Python33\lib libraries lapack_atlas not…
-
1
votes1
answer332
viewsProblems installing numpy module in windows by Pip
I can install another module using the pip, except the numpy. I have tried other installation ways using the easy_install and installation by src, unsuccessful as well. See the exit of the…
-
1
votes2
answers540
viewsPython: index 5324 is out of Bounds for Axis 0 with size 5040
Hello, everybody, I have a Python code that reads the 5040 numbers of a TXT file to perform a simulation, as shown in Figure 1. Then the code creates a B(s) function, which is used in the commands…
-
1
votes0
answers63
viewsI can’t install numpy
When calling a Python application appears written Traceback (Most recent call last): File "C: Users benev Onedrive programaþátio ML classificacao.py", line 15, in from sklearn.naive_bayes import…
-
1
votes1
answer57
viewsNumpy delete method doing strange thing
i was testing the delete method of the array class of the numpy library and a strange thing happened: I had the element of Indice 0 deleted from the array, but the element of Indice 1 is deleted. I…
-
1
votes1
answer1473
viewsManipulation of columns with pandas
I’m running a regression where I have 3 parameters and a column with categories. As sklearn does not recognize categories I turn them into Dummies ( create a column for each category and fill with 1…
-
1
votes1
answer4407
viewsHow to make a frequency distribution table in Python?
Good afternoon, One question: Could someone enlighten me on how I can make a frequency distribution table: classes; absolute and relative frequency; cumulative form; average values of each class.…
-
1
votes1
answer75
viewsProblem with numpy matrix
I’m having a problem using NUMPY. It has an array testeSolucao, of that kind <class 'numpy.matrixlib.defmatrix.matrix'>, And I need to get the least amount of it, but I can’t. At first I…
-
1
votes1
answer396
viewsWrong square parentheses (square brackets)?
I have this function in Matlab cn = reshape(repmat(sn, n_rep, 1), 1,[]); in Python I have the following code: import numpy as np from numpy.random import randint M=2 N=2*10**8 ### valor de Dados…
-
1
votes1
answer1878
viewsMatrix scheduling in Python
I have problems trying to scale a matrix 5x5. First I made a null line go to the last line of the matrix (it worked out), then I tried to make a line that had the highest index be below that which…
-
1
votes1
answer3590
viewsSum all columns of an array using numpy. Is there a better way to do it?
I did so: import numpy as np #soma de todas as colunas de mat! mat = np.arange(1,26).reshape(5,5) print(mat) lista =[] for i in np.arange(0,len(mat)): lista.append(np.sum(mat[0:,i:i+1]))…