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
-
1
votes1
answer336
viewsPython - How to add add values between row and column in ndarray
Hello, I am having the following difficulty, this because I am working with numpy now, I am inexperienced... Well my problem is this, I have a tuple (w, t), and the t repeats itself, so that I want…
-
1
votes1
answer110
viewsHow to transform a numpy.array of size 497305 into a smaller 4999 without adding new elements in the calculation?
I’m analyzing an audio and my scikit ML model generates an array of probabilities that certain element in the array corresponds to a category "A" used to train the model. Each element of the array…
-
1
votes1
answer120
viewsNumpy complex dType, with fixed array of variables, using fromfile function to import binary file
I am reading a complex binary file, where there is a fixed structure of 'array' of values, someone could help? The structure is: 8 bytes = Long Current Time (unixtime stamp) 8 bytes = Long Current…
-
1
votes1
answer143
viewsNumpy Array Error With dtype=numpy.uint8
The code below works normally, however the elements are "objects". M = numpy.array([[1,2,3],[1,2],[1,2,3,4]],dtype=object) However, when executing the code below, I receive the message "Setting an…
-
1
votes1
answer388
viewsProblem when installing Numpy
Good morning guys, I was trying to install Numpy in this machine... I ran the command "Conda install numpy" ai worked...but when I ran "Pip install numpy", it returns this error.…
-
1
votes1
answer468
viewsmodule 'cv2.cv2' has no attribute 'COLOR_BRG2GRAY'
I am resizing images from a folder and am encountering the following error: module 'cv2.cv2' has no attribute 'COLOR_BRG2GRAY' Code: pathC = './cityscape/' dirs = os.listdir(pathC) #Resize para o…
-
1
votes0
answers120
viewsDefine sections in a color recognition program
I am working on a project, which next year will become my TCC. I am learning the language of Python, and for now I have had some advances. I was reading about computer vision, but I still have some…
-
1
votes1
answer110
viewsproblem in converting normal matrix to numpy
The program organizes is made to organize the lines, based on the value of the third column, I did the program and it worked, but when I use numpy matrix, gives the error below. i need to use numpy…
-
1
votes2
answers1413
viewsHow to turn list into array
I have a csv which contains 2 columns one with a list of 200 numbers (0.3,0.4,08...) and the other a name. This file has 50 rows of this type. I would like to turn this list of number lists into an…
-
1
votes0
answers47
viewsAbsurd performance difference between pygame.surfarray.array3d and array2d
Using the pygame.surfarray to control an image as an array, manipulating any element in an array3d is more than 5 times slower than manipulating an element array2d. See this benchmark: from datetime…
-
1
votes4
answers1713
viewsRemoving lines from a numpy array
For example I have array arr1 and I want to take a line range from that array as below, which function I can use? arr1: array([[ 1, 1, 1], [ 2, 2, 2], [ 3, 3, 3], [ 4, 4, 4], [ 5, 5, 5], [ 6, 6, 6],…
-
1
votes1
answer242
viewsMatrix transposition
want to understand the meaning of the tuple that the following code passed inside the command . transpose, I went after the documentation but it was not clear to me: arr = np.arange(16).…
-
1
votes2
answers334
viewsReturn the index of a row with the min function in Python
I am trying to find the index of a numpy matrix (cut of a face detected in opencv) and draw a line where the sum of the pixels is the minimum value. I can’t return the index. Follow the code below…
-
1
votes1
answer119
viewsCreating a CSV from 3 CSV tables
I have two CSV tables and need to merge with the unusual columns in the two tables creating a single table. However, when I write the code, it is a very long time of processing and not complete. How…
-
1
votes1
answer157
viewsPython Code Numpy Arrays Creation Problem
I’m having trouble in the following code. I don’t understand what is wrong. I believe it is in the function sigmoid where she appears not to be receiving values float. import numpy as np # sigmoid…
-
1
votes1
answer730
viewsRead a JSON file and print the data in tabular format
The file is "grids.json", whose structure is: {"students": [{"name": "Alan", "lastname": "Silva", "exam1": 50, "exam2": 80, "exam3": 91}, {"name": "Paula", "lastname": "Souza", "exam1": 95, "exam2":…
-
1
votes1
answer39
viewsMultilayer Perceptron Two-Layer Code Problem
I have a problem with the following code: import numpy as np def nonlin(x,deriv=False): if(deriv==True): return x*(1-x) return 1/(1+np.exp(np.float32(-x))) X =…
-
1
votes2
answers143
viewsFind arrays with the shortest distance
I have a array_objetivo and would like to find the id and the distance (Euclidean in this example) of n arrays closer to him that are in array_all. Following are examples of arrays. array_objetivo =…
-
1
votes1
answer208
viewsNeural Networks can’t Multiply Sequence by non-int of type 'float'
Hello, I need to implement a perceptron to linearly classify 2 species (Iris). I’ve already scoured the internet for solutions and I can’t get out of the problem I took a code on the internet and…
-
1
votes0
answers39
viewsHow to create a column based on another dataframe?
I would like to know how to create a column on a dataframe based on the code of another Python dataframe. For example, I have: df A: letra c b d c a df B: letra codigo a 10 b 20 c 30 d 40 Expected…
-
1
votes1
answer58
viewsRemoving whitespace from a Numpy Array
I need to manipulate an image and identify the objects inside it. But the answer I get comes with white space and I’m not able to handle to remove these white spaces. Code: from imageai.Detection…
-
1
votes0
answers92
viewsProblems in the Results print()
I’m writing a code that calculates probabilities based on a particular Excel database. When doing this in Excel I have the final result in the column "Probability3 %": Now I need to do the same, but…
-
1
votes1
answer761
viewsHow to create a dataset to work with Keras classification
I have a series of images (12500 in total) in rgb format and I want to create a dataset to work on Keras. I want to leave them in a format similar to the Mnist dataset...with Shape (12500,50,50).…
-
1
votes2
answers47
viewsHow to remove dtype from dataframe line?
Running the code: def novacoluna(df): coluna_adicionada = {} coluna_adicionada['retorno_diario']= df['quota_value']/df['quota_deslocada'] return pd.Series(coluna_adicionada,…
-
1
votes1
answer82
viewsHow to group data from another grouping?
I have the following dataframe: x= {"Nome": ['Carla','Rafael','Juliana','Carla','Carla','Juliana','Rafael','Juliana','Rafael'], "Salario": [1200,1500,2000,1230,1250,2050,1700,2500,1750]}…
-
1
votes1
answer282
viewsGenerate XML file of more than 1 Mi of records with Xml.etree.elementtree in python
Please, how can I generate an XML file, with Xml.etree.elementtree in python, but in such a way that it creates the file of 5 thousand in 5 thousand resgitros, without the need to wait to load the…
-
1
votes1
answer442
viewsAdding a column of numbers 1 to a numpy array
Let X be the numpy array below: array([ 6.1101, 5.5277, 8.5186, 7.0032, 5.8598, 8.3829, 7.4764, 8.5781, 6.4862, 5.0546, 5.7107, 14.164 , 5.734 , 8.4084, 5.6407, 5.3794, 6.3654, 5.1301, 6.4296,…
-
1
votes1
answer104
viewsHow to change the background of a chart with Python 'Seaborn'
I try to change the background of my chart with the 'Seaborn' module, however, I am not successful. I installed the module today (16/04/2021). code: import matplotlib.pyplot as plt import seaborn as…
-
1
votes1
answer218
viewsError passing numpy.core. _exceptions.Ufunctypeerror: ufunc 'subtract' Did not contain a loop Signature matching types (dtype('<U21')
Basically I have the following code: import numpy as np def localize(aux1, aux2, aux3, aux4, aux5, aux6): search = np.array([(aux1,aux2,aux3,aux4,aux5,aux6)]) B1A =…
-
1
votes3
answers348
viewsArithmetic operations where some Dataframe data is not int in Python (pandas)
I am working with some data from IBGE and I meet with two spreadsheets that I need to take their percentage. The formula for this is very simple, ie: percentage = (dividend / divisor) * 100…
-
1
votes1
answer36
viewsHow do I count how many duplicate lists there are in a python numpy array?
Hey, guys, what’s up? I am new to the machine learning study and I come here to ask for a help on how I can proceed to count how many sub-lists have the same value in an array in python numpy as the…
-
1
votes2
answers528
viewsApply dynamic filter to a dynamic dataframe in Python Pandas
TL;DR Does anyone know how to apply a filter that will sum the values of a column of a dynamic table? The problem Well, I’ll show you the Dataframe first, it’ll be easier to explain. dados =…
-
1
votes1
answer36
viewsNumpy copy method does not create a deep copy?
I’m taking a look at Numpy’s arrays and saw that method copy should make a deep copy array. When I create an array of strings or numerical values this seems to be true. However, when I create an…
-
1
votes1
answer66
viewsUnboundlocalerror: local variable 'res' referenced before assignment - raster image scanning error (like numpy array)
I created a program that takes raster images (created in arcmap) and recognizes their polygons (their divisions). First, what I did was turn the image into a numpy array. Follow an example image…
python python-3.x array numpy image-processingasked 3 years, 5 months ago Sara Isabel Aleixo Perestrelo 13 -
0
votes1
answer198
viewsHow to run a code outside a directory in Python?
I tried to run the code saved on desktop. However, Python Shell showed Could you help me? Thank you, Marcos Miotti…
-
0
votes1
answer65
viewsSelect specific day in an np.array containing datetime
I have a np.array.astype('Datetime[s]') called T with several days at random times. I need to select a few days for separation. I tried to: for i in np.arange(MinTime,MaxTime,np.timedelta64(1,…
-
0
votes0
answers734
viewsHow can I plot a spectrogram in real time by reading data from an ADC such as the "MCP3008" connected to the Raspberry GPIO?
My idea will be to read data from an ADC such as the MCP3008 connected to Rasperry’s GPIO, from the readings plot a real-time graphics of the signal processed by a FFT(fast Fourrier transform) or…
-
0
votes2
answers135
viewsAdding points in a known data range
I am working on data analysis using Python and for this I am training SVC and K-Means algorithms. The data used for the training have a fixed spacing between each sample, because they are sampled by…
-
0
votes1
answer118
viewsI’m trying to get my chart started from position 0 using hist()
Using USAGE_PLOT became easy to do but I want to do and learn how to use Hist. the same way it is in the image below where it was used usage_plot(trip_data, 'duration', ['duration < 60'],…
-
0
votes1
answer45
viewsIdentifying the most effective method of identifying the central element of a matrix
I have the following algorithm: import numpy as np matriz = np.array(np.zeros(81).reshape(9, 9)) for i in range(1, matriz.shape[0], 3): for j in range(1, matriz.shape[1], 3): matriz[i, j] = 255…
-
0
votes1
answer2140
viewsHow to define the tangent function in python?
I would like someone to help me define the tangent function using python with constraints at points where the function does not exist (pi/2 + k*pi(k integer). Thanks in advance.
-
0
votes1
answer170
viewsReceiving Nan (not a number) when reading a file. CSV with numpy
Using python 3.6.5 import numpy as np valores = np.genfromtxt("arquivo.csv",delimiter = ";",skip_header = 1) print(valores) CSV file.: Valores1,Valores2,Valores3 10,20,30 40,50,60 70,80,90 34,54,23…
-
0
votes1
answer361
viewsHow to mount an array in python with undefined value of i and j
i am beginner in python and I am in doubt in matrix mounting. In case I did the following: import numpy as np n=3 A = np.zeros((n*n,n*n)) j= 2 i = 2 k = i+n*(j-1) a = -4 L1 = i-1+n*(j-1) a1 = 1 L2 =…
-
0
votes3
answers347
viewsImport csv as float
I am with the following problem, I am importing a basis for python, however I can not manipulate it (make average), by the same as str, I need to import it all values come as float.…
-
0
votes5
answers1043
viewsMatrix Nxm (2D) in Python with Numpy
I’m trying to solve a college activity, but I couldn’t transpose the logic into the code. The case is as follows: "The user will enter two integers. These integers will determine the size of the…
-
0
votes1
answer530
viewsHow to print only the first column of a dataset with numpy?
How to print only the first column of a dataset with numpy? My code: import numpy as np data = np.genfromtxt("iris.data",delimiter = ",",usecols=(0,1,2,3)) print(data) My dataset (part of it):…
-
0
votes1
answer546
viewsMinimum value of each Python array column
import numpy as np X = np.random.rand(4,3) print("X: \n", X) XMin = np.zeros((1,3), dtype=np.float64) for j in range(3): print("X[{0}]: {1}".format(j,X[j])) minimo = np.amin(X[j]) print("minimo: ",…
-
0
votes1
answer2655
viewsPandas iterrows, how to make the second looping using index
for index, row in candles.iterrows(): if (row['Twintower'] == 1): I would like to make a second looping from the moment he finds this condition, ie from this index down, or Row down, tried several…
-
0
votes1
answer361
viewsAllocate day period to hours
I have the following df: df = pd.DataFrame({'hora completa':['21:35:00', '22:16:00', '00:50:00', '09:30:00', '14:30:00']}) print(df) hora completa 0 21:35:00 1 22:16:00 2 00:50:00 3 09:30:00 4…
-
0
votes1
answer211
viewsPyinstaller generating error to import numpy library
Good afternoon, I am creating a python project, and need to get a executable . exe to run in any windows without having python installed. However, what happens is that when I open the generated…