Questions tagged as 'python'

2
answers

Generate a string of random numbers with a specific length

I wanted to know how I could create a string of random numbers by entering the length that the string should have. For example, that the program generates a list between 1 and 9 and has a length of 3 characters. Thanks     
asked by 31.05.2018 / 12:33
2
answers

Is there a way to create a list for each item in another list?

Suppose I have a list like this: l=[20,30,40] How do I create 3 lists like this: l1=[2,0] l2=[3,0] l3=[4,0] PS: I came up with this question to find how to multiply each digit of a number in a list. For example, from the list [22,23,24...
asked by 24.05.2018 / 04:22
2
answers

Python Groupby pandas sums of strings and floating

I am trying to unify certain columns of my csv with pandas. The problem is that I want to add the values of Imp and Rev but the Categories I want them to come together and look something like this: sitio_id;url;Imp;Rev;Categorias http://url.co...
asked by 16.05.2018 / 20:37
1
answer

Add values from a list to a python dictionary

I'm making a code which has a list list which contains a name and an integer (which is your age) and I want you to add to your 'category' from your age if we could call you from That way, this is my code: listP = [['john', 20], ['alberto', 20]...
asked by 31.03.2018 / 04:28
2
answers

Count the words repeated in a dictionary in Python

I would like to count all the repeated words in this dictionary and group them in another dictionary. data = [{'text': 'Real Madrid', 'type': 'ORG'}, {'text': 'España', 'type': 'LOC'}, {'text': 'Real Madrid TV', 'type': 'MISC'}, {'text': 'Espa...
asked by 11.08.2018 / 00:27
2
answers

try to simulate the command tail and head with python in windows

I'm trying to create software that simulates being the linux terminal (bash) #-*- coding: utf-8 -*- import subprocess import os def clear(): subprocess.call(["cmd.exe","/c","cls"]) def ls(): dirlist = os.listdir('.') for file in...
asked by 04.04.2018 / 04:39
3
answers

Python, how to declare a variable between a max and a min?

A question if I define a maximum and a minimum using If, how can I define the number or variable that is in the middle? Thank you very much! Lado1=int(input("Ingrese lado:")) Ingrese lado:3 >>> Lado2=int(input("Ingrese lado:")) Ingres...
asked by 05.04.2018 / 22:49
1
answer

Totalize columns in single row with Postgresql

I do not understand why it is so difficult to find Documentation and advice to total or add columns in a single row with Postgresql, as it is done in excel:    I have tried with CUBE, ROLLUP and CROSSTAB, but I can not finish it.   I ap...
asked by 05.04.2018 / 18:52
1
answer

specgram in mainwindow

I am generating an audio spectrum analyzer .. I have already managed to generate the analyzer with certain features that I need, however, I can not make the resulting graphic representation appear in the main window, or that the background co...
asked by 25.03.2018 / 06:27
2
answers

Equidistant points in any straight line boundedPython

I would like to know if there is already a function to do something similar to np.linspace, but not in the range of scalars but instead of vector. That is, if I have 2 points and I draw the line between them as I can divide it equidistantly. Bef...
asked by 25.04.2018 / 22:34