Questions tagged as 'numpy'

1
answer

Systems of differential equations in Python

I have problems solving the following system of equations: import numpy as np import scipy as sp from scipy.integrate import odeint import matplotlib.pyplot as plt R1=8 R2=3 L1=1 L2=1 def RLC(I,t): di1_t=(-(R1+R2)/L2)*I[0] + (R2/L2)*I[1]...
asked by 23.11.2017 / 03:33
1
answer

Numpy Exercise (Python) [closed]

Good morning, I have to do the following exercise with python using the numpy package (I do not have loops or anything like that): Construct an array in which the value of the elements equals the sum of its row plus its column. Is ther...
asked by 20.09.2017 / 10:40
1
answer

Eliminate rows and columns of a matrix, taking into account its elements

I have to create a program that eliminates rows and columns the program has to analyze all the elements of a column and if all are 0, that column and its corresponding row is deleted for example if all the elements in column 6 are 0, colum...
asked by 19.05.2017 / 21:10
0
answers

Improve the speed by creating dynamic columns in a Dataframe

I am creating a Dataframe with the following information: import numpy as np import pandas as pd from time import time start_time = time() columns = 60 Data = pd.DataFrame(np.random.randint(low=0, high=10, size=(700000, 3)), columns=['a', '...
asked by 08.10.2018 / 22:33
1
answer

Problem with pandas.DataFrame.cumsum function

I have the following dataframe in python: month = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,1,2,3,4] active = [1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1] data1 = [1709.1,3869.7,4230.4,4656.9,48566.0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...
asked by 27.09.2018 / 17:14
1
answer

Replace values in a CSV Python

I'm lost with something. I have a csv file that I import with Pandas to be able to convert it into an Numpy array, and I have the following function to replace values in the original CSV file: # Cargamos el archivo en la variable data, com...
asked by 30.06.2018 / 18:45
0
answers

TypeError: list indices must be integers or slices, not list. Can you help me?

Here's the code import numpy from pandas import DataFrame, Series countries = ['Russian Fed', 'Norway', 'Canada', 'United States', 'Netherlands', 'Germany', 'Switzerland', 'Belarus', 'Austria', 'France', '...
asked by 01.05.2018 / 21:08
1
answer

Error "only length-1 arrays can be converted to Python scalars" when using ndarray as a function

I have the following code in Python, I have problems in the penultimate line, I do not know if calling the method initial there is an error. Can you help me? import numpy as np from math import exp,ceil def initial (x): init=0.09...
asked by 01.02.2018 / 02:29
0
answers

RuntimeWarning: invalid value encountered in multiply

I have the following program transcribed in Python from MATLAB import numpy as np from math import exp,ceil def initial (x): init=0.09*np.exp(-x**2/50) return init a = -20 b= 20 T=4 M=500 rhom=0.2 n=10 drho=rhom/n rho=np.linspace(0,rh...
asked by 04.02.2018 / 21:35
1
answer

Problem with re-dimensioning a matrix

Good, working with the numpy library in python, I discovered the following problem, when I assign a auxiliary matrix to the main matrix , the latter takes the size of the auxiliary matrix , this being the problem . Below is an example....
asked by 03.11.2017 / 15:41