Questions tagged as 'python'

2
answers

Select in Python (with BD: Postgres)

I'm not able to do a select in the PostgreSQL database. Python 3. conn = psycopg2.connect(host="localhost", dbname='postgres', user='postgres', password=postgres) cur = conn.cursor() cur.execute("select id_log, nm_ip, dh_chamada, nm_tipo, nm...
asked by 11.06.2018 / 15:51
2
answers

How do I add values from list lists?

I have a list of lists, and I wanted to add the various values to index 3 of each list, but only if there is a certain string in this list. How can I do it? For example I have this list: [['ALABAMA', 'Abbeville', 2645, 11, 63], ['ALABAMA',...
asked by 12.06.2018 / 19:49
2
answers

Create a frequency table based on another column in Python

Good afternoon, guys. I have a data set in a .csv file, containing two columns: tweets and sorting, where 'tweets' matches any tweet searched on twitter and 'sorting' matches 'positive' or 'negative'. I want to make a frequency table, word...
asked by 09.06.2018 / 18:59
1
answer

Automatic condition for a variable.

I created a character for a game using a class and within that class I put the attribute life = 10. During the course of this character, it receives some damage from enemy attacks damage which I sub. When that life reaches 0 this character dies....
asked by 08.03.2018 / 01:44
1
answer

AttributeError: 'tuple' object has no attribute 'reshape'

Error: AttributeError: 'tuple' object has no attribute 'reshape' Code: xx, yy = np.meshgrid(np.arange(x_min, x_max, h),np.arange(y_min, y_max, h)) y_pred = y_pred.reshape(xx.shape) plt.figure() In y_pred = y_pred.reshape...
asked by 02.08.2018 / 15:11
1
answer

Automate printing of files within a folder

I need to make any file that is in the folder, example c://imprimir , printed automatically, checks to see if it has something and sends it to the default printer . I've been researching in Python but I've basically been able to access...
asked by 02.03.2018 / 13:05
1
answer

How to open a file selection window in Python with GTK?

I have a Python application using GTK graphical interface. This interface consists of a screen with a data entry a button, The purpose of the program is to save data in spreadsheets in a specific directory . I need to click on the button to...
asked by 02.02.2018 / 16:23
1
answer

How to use the python round

When I use the python round it converts 1.5 to 2, but with 2.5 it leaves 2. How do I round 2.5 to 3? Being that any other number that does not contain the number 2 it rounds right     
asked by 02.02.2018 / 18:03
2
answers

Doubt when doing a ranking using django!

I'm making a game site using django and I want to do a ranking based on the score of all users! For now it looks like this: views.py : def index(request): perfis = Perfil.objects.all().order_by('-pontuacao_ultima') return render(re...
asked by 09.02.2018 / 00:38
1
answer

Passing string to time

I'm getting 2 strings in hh: mm: ss format to calculate the time passed between them in days, hours, minutes, and seconds format. I have done the split and I have the fields all separated in their own integer variables, for example: hora...
asked by 29.01.2018 / 23:02