Most voted "python" questions
Python is a dynamic and heavily typed programming language whose design philosophy emphasizes usability. Two similar but incompatible versions of Python are in use (2 and 3). Please mention the version you are using when asking a question about Python.
Learn more…8,642 questions
Sort by count of
-
-2
votes1
answer332
viewsHow to format sum() output in Python dataframe
I would like to format the result of sum(). When I use the following command: # Valor concedido de aposentadoria por ano df.groupby('Ano')['Vlr Benefícios Concedidos (R$)'].sum() It returns me the…
-
-2
votes1
answer37
viewsValue of a variable to be equal to the comparison of two variables
For example how do I make a variable equal to a comparison of two variables as in this code esquerda = light_x > initial_tx direita = light_x < initial_tx baixo = light_y > initial_ty cima…
-
-2
votes1
answer54
viewsHow do I change a line in a data file iterated in Python?
Oops! I’m trying to create a Python script that reads an external data file, which has several rows and different column numbers. The script I created follows below:` import numpy as np entrada =…
pythonasked 5 years, 9 months ago Flavio Rusch 1 -
-2
votes2
answers214
viewssyntax error in python
I’m trying to solve this code but at the time of running the syntax error on the first line. Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32 Type…
-
-2
votes1
answer34
viewsRemoving higher value from line with for
Good afternoon, I’m trying to extract the largest whole value from every line of my dataframe. I created the following code for this: for i in df.index: df["maxx"] = df.loc[i].max() df["minn"] =…
-
-2
votes1
answer103
viewsChange in button text with Kivy language
I can’t find a way to keep changing the button text every time I click it. I can change the text only once. Every time it is clicked I want to appear on lamp/off lamp. ]2…
-
-2
votes1
answer155
viewsPyqt5 and buttons that lock
I made a basic Pyqt5 application with login and registration. The problem is that when I click on any button to perform any action be it, save next or login, Python stops working. I’ve searched…
-
-2
votes2
answers170
viewsHow to exit a function and go to another function within a class, python?
would like a help I’m new in python programming, I used to program in excel(VBA) and have an instruction in VBA called "Goto" that helped me a lot, for example arrived at a certain part of the code…
-
-2
votes2
answers3533
viewsError installing Pyaudio
I installed Pocketsphinx all right, along with Visual C++ Tools, but when installing Pyaudio, it presents the following error: Failed to build pyaudio Installing collected packages: pyaudio Running…
-
-2
votes1
answer35
viewsDifficulty downloading and installing Python Libraries
I did a lot of research, but I couldn’t find a way to download and install python libraries on the computer. I’m not having an error downloading, or error installing. I just don’t know how to do it.…
-
-2
votes1
answer61
viewsPython INPUT command trims in the OUTPUT tab
When I give an INPUT command it appears in the OUTPUT tab of the Terminal and because it is in the OUTPUT tab it does not allow me to type anything. How do I make it appear in the TERMINAL tab...? I…
-
-2
votes1
answer53
viewsimport PYTHON / PANDAS
I need to import a txt and take only a few characters as below: Text: 000524WEQWE256243443507AFDAF1698100005891710232323062 Code: a = (0, 6) = 000524 b = (6, 5) = WEQWE…
-
-2
votes1
answer543
viewsTkinter Python screens
from tkinter import * import Saque #Propriedades da Janela Principal JanMenu = Tk() #JanMenu é uma instância da Classe Tk; JanMenu['bg'] = 'white' #Cor de Fundo da Janela = Branco…
-
-2
votes1
answer53
viewsError creating routes dynamically in Django
of good? Next, taking my first steps with Framework Django and having some difficulties, some managed to overcome "alone", this bone. I have a basic blog project with some views, in which shows the…
-
-2
votes2
answers152
viewserror mysql.connector.errors.Programmingerror: Not enough Parameters for the SQL statement
# script de carga import csv import mysql.connector # conexao com o banco mysql = mysql.connector.connect( host='0.0.0.0', user='root', passwd='mysql', database='mydesenv', port=3306 )…
pythonasked 4 years, 8 months ago Eduardo alberto andrade 1 -
-2
votes1
answer993
viewsHow to terminate a script with Python threads
I am working with a project and need the user to have the option to terminate it at any time, the cleanest way to do this I have found so far was by the process manager terminating the python…
-
-2
votes1
answer96
viewsPython update on Debian
My machine runs Debian 9 and wanted to upgrade Python to the latest version without modifying the Debian version. It is possible to do this through some official repository or I will have to install…
-
-2
votes1
answer105
viewsautomatic matrix with python rule
How I would create a 2-column array in python as follows. where the first column adds 0.28++ to 100%, and the second column is the percentage value of 1 column * 342.…
-
-2
votes2
answers136
viewsWhat does test_size = 20 mean?
I have the following line of code: X_train,X_test,y_train,y_test = train_test_split(X,Y, test_size = 20, random_state = 0) What does test_size = 20?
-
-2
votes1
answer127
viewshow to deal with Nan in Dataframe created with list comprehension (Python)
How can I take these NaN and leave the titles of the films, by any of the construction methods? import pandas as pd rating_data = pd.read_csv('ml-25m/ratings.csv') movies_data =…
-
-2
votes1
answer415
viewsHow to generate an executable with all my project files?
I need private data that is stored inside a binary file within the user’s own computer and for that, I want to compile all the files along with the source code within an executable. How do I do this…
-
-2
votes1
answer481
viewsPython script with a peculiar if and Else condition problem
Hello, gentlemen(the). I’m a beginner in programming and I’m learning Python. I wanted to ask a question about a program I created. The program must create a fully filled tuple with an extension…
-
-2
votes1
answer54
viewsinterface, I want her to save her name and phone in a txt list
from tkinter import * class Application: def __init__(self, master=None): self.fontePadrao = ("Arial", "10") self.primeiroContainer = Frame(master) self.primeiroContainer["pady"] = 10…
-
-2
votes3
answers92
viewsArgument error in python 3.7
So, I’ve tried every way and every time giving a different error so I decided to post here I’m getting the bug : line 66, in discount = float(print(f"The discounted view value is {price * 0.90}")…
pythonasked 5 years, 7 months ago João Eduardo 9 -
-2
votes1
answer43
viewsPython Time module with Idle error
Idle is showing this error, and I can’t find a way to fix it, it seems that it hasn’t imported the time module or is not recognizing. If anyone can guide me.…
-
-2
votes1
answer63
viewsAlgorithm repeating data from last append
I did this to add AGE and NAME in a Person Dict when it ends fill the data and Ubmita it sends this Dict to the People list. The problem is, all people add have the same values as the last, as I can…
-
-2
votes2
answers1910
viewsI’m having trouble installing virtualenv through Pip install
I’m trying to install the virtualenv to then install Tensorflow. For this I have installed Pip. I am using CMD: Pip install virtualenv After installing, when typing virtualenv, appears: 'virtualenv'…
-
-2
votes1
answer34
viewsWhat was my mistake?
Can anyone say / identify the mistake I made ? I really needed help I’m starting to learn…
-
-2
votes2
answers690
viewsAttributeerror: 'int' Object has no attribute 'value'
I can’t find the reason it gives Attributeerror: 'int' Object has no attribute 'value' class DidaticaTech: def __int__(self, v=10, i=1): self.valor = v self.incremento = i def incrementa(self):…
-
-2
votes1
answer99
viewshow to sort csv files in python by column values? Giving error
import os.path import csv from operator import itemgetter lista = [] ficheironovo = '' ficheiro = input('Escreve o nome do ficheiro orginal: ') sigla = input('Escreva a Sigla do curso: ') while not…
-
-2
votes1
answer57
viewsIs it possible to create a virtual file in Python?
I’m trying to use a modified m3u file, but I don’t want to generate a physical file for this Generating the physical image: url = "#EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:8…
-
-2
votes2
answers59
viewsI’m not getting through two lists, can anyone help me?
What I want is to find the roots of a polynomial. With this, I created a list with the coefficients of the polynomial and another list with the candidates to be roots. I need to test all of them and…
pythonasked 4 years, 6 months ago André Menezes 9 -
-2
votes1
answer73
viewsTwo python versions on Ubuntu
I think there is something wrong with my pc. It shows that both python 3.5.2 and 2.7.12 are default. How to fix this? And I tried to update the version of Ubuntu from 16.04 to 18.04 and I appeared…
-
-2
votes1
answer64
viewsError Python with PIP
I tried following command to install the dependencies of my project pip install -e $PROJETO/calculo-bonus I am Getting following error: ERROR: /calculo-bonus is not a valid editable requirement. It…
pythonasked 4 years, 5 months ago Gabriela Taccari 3 -
-2
votes1
answer149
viewsPython array [HELP]
Description: Make a program that displays the average between the highest and lowest value of an integer vector with twenty user-given elements and, at the end, displays only those elements that are…
-
-2
votes1
answer63
viewsstr.replace with Indexerror: list index out of range
I have the following code that returns ref_arquivo = open("Castalia-tratado.txt","r") for linha in ref_arquivo: valor = linha.split(" ") valor[2] = valor[2].replace('\n','') print (valor) if you…
-
-2
votes1
answer48
viewsI need help analyzing a list and printing which elements repeat equally in the list. PYTHON
Serv = [0,1,1,0,9,7] The most repeated items on the list are 0 and 1, but I couldn’t think of anything I could do to get this. I tried to fix the first element,: sound = [2,2,2,2,1,1] and definitely…
-
-2
votes1
answer182
viewsError installing chatterbot with Pip
When I install the chatterbot appears all these errors ,already tried some things and went but the chatterbot and the pyaudio tbm was not Collecting chatterbot Using cached…
-
-2
votes2
answers183
viewsPython - Pass parameter instead of modules in FROM declaration
Good afternoon, everyone. I am in a dilemma when making the FROM statement. import to import the modules, as follows below: For this utility, I do not want and cannot pass the FROM.. import…
pythonasked 5 years, 6 months ago Cleber Nandi 137 -
-2
votes3
answers2351
viewsImport csv with pandas. Column values with semicolon. What to do?
I’m importing CSV files with pandas to do a data wipe. And I’m finding a problem. Some values have ';' . For example: df[0][1] = "STREET A ; " I import csv through: df = pd.read_csv('GUAXUPE.csv',…
-
-2
votes1
answer123
viewsPython Text Message Validation
Anyone has any idea how I do to validate a text message in Python, I have a screen that when I click to register and have some incorrect information it shows an error message informing the…
-
-2
votes3
answers174
viewsDeactivate Pycharm autocomplete
Good afternoon, everyone! I came into the programming world recently and was told that starting programming without these autocomplete stands is better now in the beginning. What do you think? That…
-
-2
votes2
answers490
viewsHow to use the contents of the index in Python?
I have a list "list()" with N indexes. I would like to know how I use the content of the index and save it in a variable. For example: In index [1] is the word "dog" How do I save the content of the…
-
-2
votes2
answers63
viewsHow do I show the already used and wrong letters in the hangman game? and leave the word on the bar in maiscula?
print("#######################") print("# Jogo da forca #") print("#######################") def forca(x=0): if x==0: print(" _________") print(" | |") print(" | ") print(" | ") print(" | ") print("…
-
-2
votes1
answer2083
viewsHow to simulate pressing the enter key in Selenium?
I’m using Selenium and tried to locate the instagram post button, but I’m not getting my program to click it after typing something. I’ve tried something like:…
-
-2
votes1
answer215
viewsPhonebook
I’m developing a python program that should receive a contact’s name and phone number and store in a calendar in alphabetical order. So far so good. The problem appears when I need to implement a…
pythonasked 5 years, 6 months ago João Vitor Stéphano Martins 1 -
-2
votes1
answer44
viewsI am studying Python and using Google colab as an IDE. Using 033[m does not end the colorization. Can anyone help?
I’m learning Python and using Google colab. So I tried. print('\033[31mOlá Mundo!\033[m') print('Olá Mundo!') What happens is that the \033[m does not contain colorization and the next line and all…
-
-2
votes2
answers100
viewsHow do I restart the page if Selenium does not find the element on the page?
from selenium import webdriver from selenium.webdriver import Firefox import time url = 'https://google.com' driver = webdriver.Firefox() driver.get(url) time.sleep(10)…
-
-2
votes1
answer77
viewsHelp - How to remove blue Pycharm markup when typing
You guys, good night! Please, I would like some help for a beginner in programming. How do I remove this blue tag in the Pycharm editor, as shown in the photo, so it goes back to normal? Since…
-
-2
votes1
answer41
viewsHow to serialize a Hash object from Hashlib for Socket submission?
How is it possible to serialize an object of the type _hashlib.HASH , so that it is suitable for sending via sockets (sendall() and send()) ? With the pickle is made: hashed_Message =…