Questions tagged as 'python'

1
answer

How can I compare the output of a type () function with a string?

If I have a python script like this: texto = "TEXTO" cadena = "<type 'str'>" salida = type(texto) if(cadena == salida): print("Es un string") else: print("No es un string") I think in theory it's fine because you're comparing...
asked by 11.11.2017 / 16:46
1
answer

NoReverseMatch and Post Token in the URL in Class Based Views

I'm trying to do a simple "edit and delete" with views based on Django classes. The problem is that I'm getting these errors with UpdateView and DeleteView . One occurs when I want to redirect to its DetailView after the...
asked by 30.08.2017 / 22:53
3
answers

Replace point by comma in Python 3

Hello, I have a list of decimals that I converted to String, in order to change the points by commas. But with "replace" it does not allow me to make the change, I'm doing it this way: for i in range(len(UCL)): #UCL de corte UCL[i].re...
asked by 25.07.2017 / 23:42
1
answer

Connect SQL Server database with Python

I have this code that I started, to be able to connect to my server of SQL Server by means of Python in Ubuntu , all the components of: server, user, password, base already make sure they are correct. But when I ru...
asked by 26.07.2017 / 00:16
1
answer

Add all the values and add the value at the end

I have the following code in Python: import numpy as np from math import pi t = np.linspace(-2*pi,2*pi,16300) #Creo un vector de 16300 puntos de -2*pi a 2*pi x = np.sinc(t) print(x) I want to algebraically add all the points of x and add t...
asked by 25.07.2017 / 20:38
1
answer

Type Error with raise statement

I'm trying to write a very simple function that I saw in the book "Learn to think like a programmer with python": def elige_numero(): x = input("Escriba un número: ") if x == str(17): raise('ErrorNumeroMalo', 'El 17 es malevolo...
asked by 16.09.2017 / 17:38
1
answer

Combine C ++ and Python

When creating graphical interfaces with C ++ I see a world, and I have been reading the possibility of combining two languages, one of them C ++. My question is, could you do all the essentials with c ++ but the graphical part with Python? That...
asked by 04.09.2017 / 04:28
3
answers

Do operations on columns in a Dataframe loop

I want to do calculations on three columns of an array values_array . def calculateAllEMA(self,values_array): df = pd.DataFrame(values_array, columns=['BTC', 'ETH', 'DASH']) for i,column in enumerate(df[column]): ema=[]...
asked by 11.08.2017 / 18:01
1
answer

Make the diagonal of a matrix 0. Python

Good morning everyone, I would like to be able to make the diagonal of a matrix equal to 0 with some type of command, does anyone know how? Is there any numpy that can do it? for example SO: [,0] [,1] [,2] [,3] [,4] [0,] 0 0 1...
asked by 03.08.2017 / 10:12
2
answers

Problem in assigning arrays in Python

Hello, I do not know if this question has already been answered, but my problem is this: When assigning a global variable to a local variable of a class, changing the value of the local variable also modifies the value of the global v...
asked by 06.08.2017 / 18:31