Questions tagged as 'python-2.7'

3
answers

How to print without line break in Python

matriz = [] def create_matriz(a, b): for contador in range(a): matriz.append( [0] * b ) def print_matriz(txt): cont = 0 for j in range(a): for i in range(b): if txt[cont] == "0": matriz[i][...
asked by 06.06.2017 / 06:15
1
answer

Executing external programs with Python

I would like to reduce the size of several Mp3 files in a directory with: ffmpeg -i k.mp3 -acodec libmp3lame -ac 2 -ab 16k -ar 44100 k_.mp3 where K is the name of Mp3 (k from 1 to 8): Itriedthefollowingcode:importsubprocessforxinrange(1...
asked by 14.05.2017 / 00:43
1
answer

Go through 2D list in Python

I have the code below and I want to go through and display item by item from this list. However, I can not do this because the entire list is displayed. I ask for your help. lista = [[10,20,30,40],[50,60,70,80]] i = 0 for i in range(2): pr...
asked by 23.02.2017 / 20:29
2
answers

Handling Network Settings in Python

I work in linux environment, Python 2.7, and am needing a Python module / library that allows me to change the network settings (IP, Subnet, Gateway and, if possible, primary and secondary DNS). I checked some libraries ( netaddr , i...
asked by 08.02.2017 / 02:14
2
answers

Looping for as looping parameter while

Since the list cont would have the values: cont = ['t','f','f','t','f'] You could do something like this: while(for cont in cont == 'f'): pass     
asked by 26.07.2016 / 14:30
1
answer

Adding character to string

Good person my doubt and the following, I have the following situation: I have the following variable >>> a = "EXAMPLE" Let's suppose I had to remove the letter "M" from the string, in this case I would do >>> a = a.r...
asked by 29.12.2015 / 04:38
1
answer

Transform query into dataframe [sqlalchemy + pandas]

I'm new to python and want to create a function that queries the database [mysql] and converts it to a dataframe so that it can be emailed in .csv format later. But I'm having trouble with this query conversion to the dataframe. Here's my...
asked by 06.10.2015 / 20:42
1
answer

Find common values in two different dataframes

Editing the question: I have two DataFrames of different sizes, they are: df1 = pd.DataFrame({'bc': bc_1}, index=altura_1) df1.shape()=(73,1) >>> print df1 bc 1.175441 0.002884 1.115565 0.001905 1.055689...
asked by 27.08.2018 / 18:40
1
answer

Class definition within a function or another class

I've seen in some scripts definitions of classes within other classes or functions like this: class Grok(object): class Foo(object): ... ... What is the reason for this practice? Is it just to not allow direct instantiatio...
asked by 09.07.2018 / 06:46
1
answer

Convert fraction of time in the format hh: mm: ss

My time data set is stored in the variable time = [0., 0.08333333, 0.16666667, 0.25, 0.33333333, 0.41666667, 0.5, 0.58333333, 0.66666667, 0.75, 0.83333333, 0.91666667, 1., 08333333, 1.16666667] p> Can anyone tell me if there is a simple way to...
asked by 05.02.2018 / 16:25