Questions tagged as 'numpy'

1
answer

Obtain opposite polynomial

I know it can be silly but I can not find how to do it. I want to know how I can calculate the opposite polynomial created in Numpy regardless of its degree . Example that does not work for me: import numpy as np p0 = np.poly1d([2., 0.,...
asked by 19.04.2016 / 21:22
1
answer

matrix edition

I am writing a program that I read a matrix and if the value of the element is less than a value rewrite it as zero and if it is greater than the value, leave it as such. I do this: lis=open('ej.txt','r') A=lis.read() A=np.genfromtxt(StringIO(...
asked by 23.08.2016 / 02:05
1
answer

Create and plot fix of slopes between points

Good afternoon everyone, I'm trying to create an array with numpy that contains the slope between each of the points made with the arrays x e y to finally graph them with matplotlib . These are the steps that I am c...
asked by 25.01.2016 / 00:33
3
answers

How to iterate in a dataframe for a certain number of rows?

I have the following dataframe: import pandas as pd import numpy as np data = pd.date_range('20180101', periods=300) df = pd.DataFrame(np.random.randn(300, 5), index=data, columns=['open', 'high', 'low', 'close', 'volume']) I...
asked by 27.12.2018 / 14:54
1
answer

Difference between numpy.empty and numpy.array

np.empty is considered a junk vector in which it serves to know what type of data contains the vector and a np.array returns an array, but in which case it is more convenient to use each of them.     
asked by 12.12.2017 / 22:23
1
answer

matrix staggering in python

I have problems when trying to stagger a 5x5 matrix. First I made a null line go to the last row of the matrix (it worked), then I tried to make a row with the highest index fall below the one with the lowest index, but on the line: if pivos_i...
asked by 14.10.2017 / 20:05
1
answer

Create an executable from a python script (NumPy)

Sorry that seems like a very simple doubt, but it is the first time that I do this and I am having difficulties. I have created with spyder, a software that brings anaconda, a calculator of systems of equations, in which I have used the numpy mo...
asked by 07.05.2018 / 21:38
2
answers

Compare a coordinate list with another and its radius

Good! Let's see I have a function that generates a list ( List A ) of coordinates in numpy .    [[1,1][1,6][3,5][5,7]] < - (for example) And I have another list ( B list ) with more coordinates (Also in numpy ) format...
asked by 27.01.2017 / 10:19
1
answer

TypeError: only length-1 arrays can be converted to Python scalars (2)

Hello again I am with the same error but in a different place. Veran I have the following code import matplotlib.pyplot as plt import numpy as np from py_expression_eval import * def f(exp, var, x0): p = Parser() p.ops2['^'] = n...
asked by 03.03.2017 / 01:49
1
answer

Is the result incorrect with Numpy in Python 3?

I was doing matrix exercises with numpy, but apparently it generated an error in the final answer: As we can see the final result of Z*Z is: [[9,4,1], [1,0,1], [1,4,9],] But after a suspicion I compared the results by hand w...
asked by 13.07.2016 / 06:13