Questions tagged as 'numpy'

3
answers

Is there a more efficient way to dynamically create an array from another array by filtering the contents of the array first?

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 way I know to create arrays dynamically...
asked by 15.12.2013 / 17:48
6
answers

Convert 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 to: b = int(a) It gives an error because it is on...
asked by 06.01.2014 / 00:50
1
answer

Copy a numpy.array without modifying the original

Given a numpy.array like the following: r = np.arange(36) r.resize(6, 6) That 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], [2...
asked by 03.11.2016 / 23:38
1
answer

Retrieving list list values in python

I've tried several things and still can not figure out what the problem with my code is, it's a simple code. With numpy I put the txt values in the arrays array and I want to make some copies for two other lists, mensagem and no ....
asked by 22.09.2015 / 19:05
1
answer

numpy.diagonal returning read-only copy even in version 1.10

I'm doing a program in Python where I need to change the diagonal values of an array. The following code snippet should be sufficient to understand the general idea (it changes to% w_ of% the value in the first position of the main diagonal of t...
asked by 28.10.2015 / 20:17
2
answers

How to install numpy and other modules?

I need help with how to install numpy. I tried to install pygame using pip but it did not work and I was confused on how to install modules or packages. Using python 3.5.0 in Windows 10 pro     
asked by 16.11.2015 / 00:09
1
answer

What is the difference between type and dtype?

Based on a previous question , I saw 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 dtype exists. What is the differenc...
asked by 23.03.2017 / 17:29
2
answers

How 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 I can display the number of people currently detected on the webcam. from __future__ import print_function #importa a funcao da biblioteca...
asked by 03.06.2018 / 18:22
1
answer

Summarize all columns of an array using numpy. Any 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])) print(np.array(lista)) The output is correct:...
asked by 05.05.2018 / 22:42
1
answer

Python Interpolate Txt

Good evening, I recently started the program in python because of an elective that I have at university, but my knowledge is still minimal. My teacher gave a job to do where I should create a code that read a table Precos.txt like this: 1, 69...
asked by 20.02.2017 / 22:58