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
votes2
answers2474
viewserror to import pandas library and numpy
Guys, I have a problem to import panda library and numpy for my project, when I try to run on pycharm... the following code, this error presents: code: import pandas as pd import numpy as np error:…
-
0
votes1
answer54
viewsStep error in np.arange
I have a problem in the arange that does not return accurate values. import numpy as np for i in np.arange(0.0, 5.0, 0.2 ): print(i) The result is: 0.0 0.2 0.4 0.6000000000000001 0.8 1.0…
-
0
votes2
answers711
viewsFind the second highest value
I need to find the second highest value in the iris file. entranda de dados url = 'https://archive.ics.uci.edu/ml/machine-learning- databases/iris/iris.data' iris = np.genfromtxt(url, delimiter=',',…
-
0
votes1
answer87
viewsI believe it’s an overflow mistake
I created two arrays as follows array1=np.arange(1000000) array2= np.arange(1000000) and when I did the following operation: array1*array2 I got that answer: array([ 0, 1, 4, ..., -731379964,…
-
0
votes1
answer45
viewsTransform Pandas str objects into numeric values
How do I use Python to transform the following string: [[98 9] [55 16] [9 50] [68 0] [24 1] [80 16]] in two numerical vector chains (the first string containing the first values: 98 55 9 ... and the…
-
0
votes2
answers526
viewsApply a function to each element of a python matrix
I need to apply a lambda function to all elements of a matrix in and it returns a matrix of the same size type like this: i have the matrix mat in numpy style: mat = array[[1, 2, 3], [4, 5, 6]] and…
-
0
votes2
answers159
viewsIndexing error when separating line information
import pandas as pd import numpy as np import matplotlib as plt df = pd.read_csv('dito_julho.csv') df.head() campanha valor 1 Prospect | 5 dias | Com crédito 2 2 Prospect | 5 dias | Com crédito 5 3…
-
0
votes2
answers239
viewsSelect only a part of the Dataframe title
Imagine the following situation, I have a Dataframe with any name. Within this Dataframe I have columns with the following titles More(abc), Less(abc), Sub(abc), following the data of each column.…
-
0
votes1
answer84
viewsWarning pandas, 2 loopings!
Guys I’m having trouble with this looping, because it’s a situation that I can’t solve with np.where, why does the DataFrame to find the value of the gain or loss from another condition, which comes…
-
0
votes1
answer2111
viewsHow to convert values into percentage of a "total" column into pandas?
Hello! I’m learning about Python and Numpy, but I’m having trouble working with percentages. Considering that the total column corresponds to 100%, as I do to obtain the respective percentages of…
-
0
votes0
answers1022
viewsHow to change bar colors individually in matplotlib?
Hello! Can anyone explain to me how the principle works to change the colors of the bars individually? All I can do is change the color of the whole chart. For example: From Blue to Black / From…
-
0
votes1
answer179
viewsRead Numpy files in Jupyter Lab
Good afternoon, I am currently developing an Artificial Intelligence project. In the current phase of my project, I have my neural networks implemented and I am in the phase of training the neural…
-
0
votes1
answer71
viewsPython: How to assign values in n arbitrary dimensions?
I have two n-dimensional arrays (i.e. Len(A.Shape)==Len(B.Shape)), and one 'fits' in the other (be the first A, the second B, for all dimensao i of A and B, A.Shape[i]>=B.Shape[i]) I want to…
-
0
votes1
answer53
viewsError with np.random.suffle, result None
I am trying to mix a dataset with 3 columns and then divide it in half for use of one part for training and another for ML testing. I’m using the code: Dataset = np.append (col1, col2, axis = 1)…
-
0
votes1
answer89
viewsAdding a number to an array gives an index problem
I have tried everything and could not add the number 1 at the bottom of the list predictors. Gives the following error: new_inputs[i] = np.append(inputs[i],one[i]) Indexerror: list assignment index…
-
0
votes1
answer243
viewsError importing pandas into Jupyter Notebook
I can’t care what pandas in Jupyter Notebook. Error shows this message: Runtimeerror: The Current Numpy installation ('c: users Augus analise_data lib site-Packages numpy\init.py') fails to pass a…
-
0
votes1
answer167
viewsHow to transform an array of arrays into a nested array in python
I’m looking to transfer an array of arrays in a nested numpy matrix, i.e.: array[array[1,2],array[1,2,3],array[8]] in array[ [1,2,nan], [1,2,2], [8,nan,nan] ]. That’s right when I convert to pandas…
-
0
votes1
answer36
viewsEllipsis in numpy array
What the object means ... in a numpy array. I am working with a database and when I use the Unique method in one of the columns, between the objects it returns this ... What these reservations…
-
0
votes1
answer61
views3d graph with dimension error
I’m trying to plot a graph in 3d. I already have in 2d. All quiet there. It is a matrix with the values of the amplitudes of a wave propagating in a tab. But I would plot the values of the matrix as…
-
0
votes1
answer454
viewsInsert values to a 3D numpy array
Hello. I created the following array numpy as below: import numpy as np x = [350, 500, 800, 900, 1000] y = [1100, 900, 1250, 650, 1200] z = [50, 150, 300, 200, 500] arr_2d = np.array(list(zip(x,…
-
0
votes1
answer1645
viewsCumulative sum per line
Good afternoon colleagues I would like a help. In the code below i Gero a new column (accumulated) using cumsum. The result is a cumulative sum for each row. However I need to bring the accumulated…
-
0
votes0
answers275
viewsSplit dataframe according to number of lines
I wonder if it is possible to separate in a way a date frame of +- 300000 lines in pre-set amounts of lines and save in xlsx as the headers each part. I thought of using Loc, but I would have to use…
-
0
votes0
answers157
viewsExtract numpy arrays from a dictionary iteratively
I have a dictionary of the following kind: data = {'neuron4':Numpy array, 'stim':Numpy array, 'neuron3':Numpy array, 'neuron2':Numpy array, 'neuron1':Numpy array} I tried to do something like for…
-
0
votes1
answer81
viewsGenerate a python array of multiple variables
Hello! I am trying to generate a function that reads imported data from a "csv" file and converts it to an array. The data of one column is integer, and of the other column is an intercalation of…
-
0
votes0
answers56
viewsVLOOKUP IN PYTHON USING MERGE
I have a dataframe called df with a column of countries in several languages and another dataframe called ct that I have a column with countries in several languages and another column with the same…
-
0
votes2
answers38
viewsComparison of content in matrices
Have some python solution to use something similar to np.all in arrays that are filled with strings or ints? Below an example of what I wish, perform the comparison of a row of the matrix to verify…
-
0
votes1
answer43
viewsHow to add a number to an array?
Hello! All right with you? I’m making a code and I needed to define a function: def sigmoid (v): return 1/(1+np.exp(-v)) Only what I’m assigning to the function is an array 2d. My question is: in…
-
0
votes1
answer370
viewsGroup by com Python[Nympy or Pandas] - Bring the 1st line and last line by date
Good afternoon forum colleagues. I’m having a hard time bringing the 1st line and the last row grouped by date. However, I would like to bring this data in the format I am using group By in sum or…
-
0
votes2
answers658
viewsCheck if the values of a certain Dataframe column exist in a certain list using np.Where
Hello! I’ve been trying to check if a certain value present in a certain dataframe column is present in a list, using np.Where. In other words, it would look like this: df = { 'Pais': ['Brazil',…
-
0
votes3
answers84
viewsDataframe Pandas - How to use a previous value other than NA for calculation
Having a dataframe as the following example: df = pd.DataFrame([['A',1,100],['B',2,None],['C',3,None],['D',4,182],['E',5,None]], columns=['A','B','C']) A B C 0 A 1 100.0 1 B 2 NaN 2 C 3 NaN 3 D 4…
-
0
votes0
answers18
viewsDoes the true value of a number change when I change its float type.?
Change my data set to float32 or float16, is changing the "true" value of my data? If I have the value 3.6, using python and reading in float64 he remains 3.6, but it changes when I put in float32,…
-
0
votes1
answer164
viewsTransform column with Nan and string to integer
I have a dataframe with the following column: Years 0 1990 1 1990 2 1990 3 1991 5 NaN 4 1994 6 NaN ... ... Name: Years, Length: 9742, dtype: object I have already performed part of the cleaning of…
-
0
votes1
answer323
viewsCalculate the average of a variable for each type of flower in a column
In the Species column of the dataset, I have these flower species: df['species'].unique() output: array(['Iris-setosa', 'Iris-versicolor', 'Iris-virginica'] I need to average for each flower species…
-
0
votes1
answer150
viewsHow to delete two related numpy array elements?
My x and my y to plot are: x0_n125n25matriz= [ 3472.222 3501.157 3530.092 3559.028 3587.963 3616.898 3645.833 3674.768 3732.639 3761.574 3819.444 3848.379 3877.315 3906.25 3935.185 3964.12 3993.055…
-
0
votes1
answer81
viewsHow to use a collection as an element of a Python array?
I am developing a project using scikit-Learn (and pandas to handle the data) to predict the results of football matches based on previous results. As a project methodology, for each row of the…
-
0
votes1
answer53
viewsFilter Dataset from a groupby
I have the following dataframe (df_reviews) and need to remove the App versions that were downloaded less than 10 times and tried to do the steps below and a for to perform the filter on the…
-
0
votes0
answers21
viewsFix the speed of Video Screen_recorder.py
Hello, I’m doing a small project to better understand how screen recordings work. I am making a program in Python, which is working perfectly, however, at the time of running the video, the speed is…
-
0
votes1
answer70
viewsVariable value is changing automatically
I have a question about assigning values to variables. I created the following code for solving equation systems by the Gauss-Jacobi iterative method: A = np.array([[2., -1.], [1., 2.]]) # Matriz de…
-
0
votes0
answers48
viewsHow to set the columns in Sklearn’s Onehotencoder?
I’m having a small problem making an ML code for sorting set when using Onehotencoder to perform categorization. I am following a course that used the resource in the following way: dados =…
-
0
votes2
answers509
viewsFilter data from a Dataframe pandas by a specific column and the last four dates of a set of dates
I have 2 dataframes in Pandas where: Data Frame A - contains information of the available time of announcements in each program DFTmpDisp sinal cod_programa data tempo_disponivel 0 SP1 XXXX…
-
0
votes0
answers70
viewsPython error: Typeerror: 'numpy.float64' Object is not iterable
I am having the following problem when compiling this program in google collab: Typeerror: 'numpy.float64' Object is not iterable He points out the error in the line…
-
0
votes1
answer85
viewsPython/Pandas: Treatment of TXT
The ERP I’m working on is generating a . txt in the following format: ID:;1;Evento;Estado;Serial;Qtde VM;LIBERADO;471;2 Data;id_m;id_c;Data inicial;Data final 01/01/2021…
-
0
votes0
answers38
viewsPython: I need to get the area below a curve
This is my code: index = 0 T = np.zeros((300,1)) T[:,0] = np.linspace(0.01, 3, 300)[:] A = np.loadtxt('AAA_'+str(index)+'.txt') Tr = 1.0 idx = (abs(T-(Tr))).argmin() a = T[:idx+1] a = [i[0] for i in…
-
0
votes1
answer33
viewsOutput of np.Where only back a value
I am developing code to help me analyze import spreadsheets faster and better than the tools excel offers. Basically, I take a spreadsheet, convert to CSV and import pandas and numpy to analyze the…
-
0
votes2
answers58
viewsInsert values into an array with dimensions defined from a loop
Good afternoon, I am trying to save values in the form of an array from different text files, using a loop. I need the values obtained from the first iteration to be stored in the first line of the…
-
0
votes0
answers59
viewsnp.savetxt No download file CSV(Jupyter Notebook)
I developed a code to help me analyze data faster than I’ve been doing before. All the development was adapted to Jupyter Notebook used in Google Chrome, this because the company I work does not…
-
0
votes1
answer27
viewsHow to put a limit to my vector?
I am doing a work, and in it I find a vector with possible values for a variable, however, the values that really meet the answer, are contained in the restriction 1.5 < R < 2 . How I would…
-
0
votes2
answers45
viewsValue Replace with Python and Pandas
Hello, I’m trying to remove a character from a base that I extracted from a TXT file, I loaded the file with pandas but I can’t remove it using replace command, below the values I have in a certain…
-
0
votes0
answers13
viewsnp.savetxt downloads a format file ... (formatting problem)
I am editing a code that groups some values from HTML Donwloads and stores them in a list called column_b. Along with column_a (a list of values already defined), I want to do a csv and download it.…
-
0
votes1
answer30
viewsHow to add more values in a numpy matrix?
I am doing a program in python that uses matrices, I am using numpy to do them, but it is giving the following problem: I do the matrix in order to save several values, but it keeps only one. I was…