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
-
-1
votes1
answer49
viewsProblems with a python creation of Grid Tkinter
I’m creating an app using Python 3 and Tkinter and I’m time a problem overlapping the widgets, I can’t see the error in the code. import tkinter as tk from tkinter import ttk class MainFrame…
-
-1
votes1
answer312
viewsExports data to excel with python
I’m having a problem in python code, which I’m wanting to import some data that is taken from a website and it matters either for excel or for csv. as you can see in the photo, this is the data,…
pythonasked 4 years, 8 months ago Wesley Israel 3 -
-1
votes1
answer111
viewsSave report to Django Excel with filter
Good afternoon...I made a function to export report in excel that worked, however comes everything that is in the database, I wanted it to be filtered...kindly someone could help me.... function…
-
-1
votes1
answer69
viewsPython - Error 34, Result Too large
I’m trying to get a sequence of a recursive function, but it always returns me the overflow error. import math f = 1.5; a = 100; b = 10; d = 1; w = 3.76; x1 = 0; y1 = 0; z1 = 0; h = 10^-3; for i in…
pythonasked 4 years, 8 months ago Priscila Guedes 35 -
-1
votes2
answers106
viewsSaving csv file using python
I have the following problem: I have a csv file with multiple numbers. I read this file, pass a header and make the separation The problem happens when I try to save this data in a new csv file.…
-
-1
votes1
answer107
viewsProblems entering data into a table
I have a Python script that reads messages coming from the serial port. When reading messages, record them in a mailing list and send them to a SQLITE3 database. However, when executing, it presents…
-
-1
votes1
answer179
viewsConfirmation Modal with Django
I’m on my first project in Django and I’m having a hard time making a confirmed modal before deleting the record. When I press the YES button it does not direct to my URL {% url 'apiDelete' api.id…
-
-1
votes2
answers407
viewsChart with Seaborn with one of the axes being the index
I have a dataframe, it has a standard index, but replace this standard index by the name of the Brazilian states and now I would like to plot a Plot bar vertical, using the Y axis with the name of…
-
-1
votes2
answers1122
viewsLabel for bar graph - Matplotlib
Hello, I have this dataframe: I’m generating a bar graph of deaths per day, I’d like to put labels on the bars to show number for each day. plt.figure(figsize=(12, 8)) plt.bar(df2['Data'],…
-
-1
votes2
answers107
viewspython cleaning raw data manually
import pandas as pd data_r = open('rosalind_gc.txt', 'r') data_r1 = data_r.readlines() data_r2 = [] data_r3 = [] #tirar os \n do texto for i in data_r1: data_r2.append(i.rstrip()) data_index = []…
-
-1
votes1
answer54
viewsHow to reduce the number of elifs to find the letter that is most used at the beginning of the names?
lista_nomes = [] lista_idade = [] lista_sexo = [] idade_cont_menores = 0 idade_cont_maiores = 0 sexo_op = ['m', 'f'] sexo_cont_masculino = 0 sexo_cont_feminino =…
-
-1
votes2
answers2310
viewsSplit a column into two from a parameter - Python
I researched a solution but I can’t locate facing a data frame, just input lines for example. I HAVE A DATAFRAME WITH THE FOLLOWING FIELDS AND LINES: data = {'País': ['Bélgica', 'Índia', 'Brasil'],…
-
-1
votes2
answers96
viewsPython loop requesting data reentry
I have a problem in my Python code, it is giving loop. Every time I have to insert the list again to show the results. Could someone help me? Follows the code: import numpy as np import pandas as pd…
-
-1
votes1
answer385
viewsData Reader in Python
Hello to the python community. I am a student of economics and beginner in python. I’m developing a code to pursue return on stock purchase, buy and hold. However, I have a problem with the search…
-
-1
votes1
answer603
viewsNameerror: name X' is not defined - Django Rest framework
Following the tutorial for creating API with DRF, I encountered difficulties while mapping the urls. By running 'python manage.py runserver', I get the following error path('', include(loja.urls)),…
-
-1
votes1
answer24
viewsDifficulty to pass update column as parameter in Python3 function with Sqlalchemy
I’m using Sqlalchemy to work with database tables. I am creating classes for the proper tables, where I have as methods of these classes, Insert, filter_all(), etc. I’m using the following class…
-
-1
votes1
answer52
viewsLinear split #python random_state Seed recognition failed
If random_state is not working, whenever I run into jupyter, it comes with a different precision.. Can anyone tell me the error? thanks in advance :D # estimador de aprovaçao baseado nas notas das…
-
-1
votes1
answer80
viewsMerge array to stay 2 columns
I am with 2 separate array of 1 x 1000 and would like to stay with a single of 2 x 1000. r = array([0.56155503, 0.98218785, 0.95613911, 0.98307298, 0.55173653, 1.04626122, 1.01631092, 1.03858722,…
-
-1
votes1
answer90
viewsConvert int to str for loop
I would like the variable of input() retain its type int were only converted to string when exclusively entered with’s' digit so that I can exit the loop, without changing the while, there is some…
-
-1
votes1
answer111
viewsPEP8, invalid escape Sequence, what’s wrong with the code
I’m learning to use webscraping in Python (version 3.7). I’m dealing with regular expressions and writing this code: from urllib.request import urlopen from bs4 import BeautifulSoup import re html =…
-
-1
votes1
answer120
viewsHow to check if the Tkinter window has been closed Python?
I’m having a problem with the code, my code is bigger than that, this part is just the login and password part, my problem is that the code works if the window is closed by X, has how to check if…
-
-1
votes1
answer61
viewsWeb Scraping iterator taking only elements with odd index
was making Webscraping from a sales page of cars and for some reason while iterating the data to collect the Mileage data round the iterator simply repeated the items, ie : 27000 27000 48000 48000…
-
-1
votes1
answer66
viewsPython - Pytest Typeerror
I am assembling the pytest of the function calculate from the class Sum of a calculator, but as the function calculate receives an "object" as argument, it is giving error. Follows the codes.…
-
-1
votes1
answer29
viewsWhy is my function turning some strings into separate characters when sending them to the CSV file?
I created the function below to save the information of a Json to a CSV. But it saves what is being displayed in the OUTPUT. I need the information to stand next to each other and the words not to…
-
-1
votes1
answer53
viewsSet instance attribute automatically from parameters of another instance attribute (same class)
Good afternoon or good night. I was doing the POO course of Gustavo Guanabara which is in PHP, in class 7b is defined a rule where from the instance weight attribute is defined the category…
-
-1
votes1
answer65
viewsError in assigning Try and Exception
We are having difficulty executing an activity of POO. To run the code block where the method we use displays an unexpected output (Semantic error). def acionamento(self, estado, nome_gerador): #…
-
-1
votes1
answer683
viewsPython script to save notepad text
I’m trying to do in python a program that gives some food options to Sario and then saves them in a notepad, but is giving error, what is wrong? error: Exception in Tkinter callback Traceback (Most…
-
-1
votes1
answer408
viewsHow to take an array within another array using python
I am trying to pick up an array of coordinates within another array in JSON document format, but am having difficulties. This is the JSON document I’m using { "bairro": "Vila Mariana", "type":…
-
-1
votes1
answer116
viewsI made a pdf reader in python with a counter to read the page of this pdf but I’m missing something and my "reader" only reads the last page:
# o contador começa em -1 pq o para ler a primeira página tenho que começar do indice 0 contador = -1 def acessarPDF( c = contador): import PyPDF2 arq =…
-
-1
votes2
answers193
viewsPrint characters to a given letter and include line breaks at the end
Create a program that receives an uppercase alphabetic character as input and displays the alphabet sequence from 'A' to the read character. The program must repeat the procedure until the character…
pythonasked 4 years, 6 months ago user186294 -
-1
votes1
answer44
viewshow to take a single text from a specific line in a python txt file
I am making a mini system to register products and change their quantities, but I am dealing with a problem of deleting a part of the text in a certain line, for example: '00000 1' to '00000…
-
-1
votes1
answer79
viewsPython - update() failure to merge dictionaries
Hello I searched and found that dictionaryA.update(dictionaryB) is able to join the two dictionaries together. I tested and it actually works. But in the little exercise program below, it does not…
-
-1
votes1
answer186
viewsHow to get the file name to be opened with my program by clicking on this file?
I created a music player in the Python language and I would like to know how to play a song with my program by clicking on the file. For example when I open a song now, it automatically plays on…
-
-1
votes1
answer95
viewsSplit by columns in CSV conversion
I need to do a CRUD for student registration, and then soon after, convert this data to a spreadsheet, and for now, the save part to. csv is like this: alunos_json = json.dumps(alunos, indent=True)…
-
-1
votes2
answers39
viewsRemove list duplicity with Python
I need to remove objects that have the same conta, saldo_devedor, and that the limite be equal to 0. list = [ { 'conta': u'1.3.02', 'saldo_devedor': 999.08, 'limite': 2500.0 }, { 'conta': u'1.3.02',…
-
-1
votes2
answers52
viewsI’m not finding the highest value in a list with random values
I need to find the highest value in a list of 50 random numbers. To generate these numbers, I used the functions sample and randint. So to generate the list I use: lista = [sample(range(0, 200),…
-
-1
votes1
answer239
viewschange user-agent in python webdriver Selenium during navigation
need to perform the following procedure: 1) browsing with user-agent mobile (I can do) open the site www.site.com and login (I can do) 2) Change user-agent to mobile(I cannot do) access an option on…
python mobile selenium-webdriver toggle user-agentasked 4 years, 5 months ago enio ricardo de farias 11 -
-1
votes1
answer74
viewsHow to page a search page in Django?
Hello, I am trying to paginate the results of a search page on Django, but without success. A class based view is responsible: class SearchResultsView(ListView): model = User paginate_by = 2…
-
-1
votes2
answers80
viewsUpdate Dict in List Comprehensions
I have some dictionaries that I need to fill recursively and for that I would like to use list comprehensions this way list_dict = [{'a':'b'},{'a':'c'}] list_dict = [dict.update({'b':dict['a']}) for…
-
-1
votes1
answer661
viewsPython sending multiple email with different attachments
I’m creating a bot in python, for sending emails to some people with different attachments, the code is like this: import win32com.client as win32 import time import os #Informações do e-mail…
-
-1
votes1
answer42
viewsInformation does not appear in the form when editing
With the primary key ID, work with the information in the views, but it does not appear in the edit(html), the fields sector and company appears. Views @login_required(login_url='/login/') def…
-
-1
votes1
answer39
viewspython timestamp argument error
I’m converting a set of dates and trying to plot a chart with the converted values but I’m having the error following, someone knows what can be? dates = data['data'] date_format =…
-
-1
votes1
answer108
viewsSave application information on exit (Tkinter)
I am making a form by Tkinter and wanted to know how I can save his information if the user closes the application by red X page, so that after he enters again do not need to repeat everything he…
-
-1
votes1
answer59
viewsProblem like Python hangman game
I’m doing a hangman game in Python, the user writes the word and then the tip, another user will play the game and can choose between play or ask for a hint but when returning the variable tip it…
pythonasked 4 years, 5 months ago Germano Lira 1 -
-1
votes1
answer82
viewsDoubt old game loop (Python)
Good afternoon, people. This is a code I saw that plays an old game. Could someone please explain to me how the Loop function evaluate and play_game is working? Specifically that part for player in…
pythonasked 4 years, 5 months ago user158657 105 -
-1
votes1
answer85
viewsI have a problem with the beginner python code
Good afternoon! I’m a beginner and I’m trying to learn python, I tried to make a program that calculated if the number typed is prime and then the program asks if I would like to calculate all the…
-
-1
votes1
answer39
viewsI cannot understand why this value is Nan in the column "[lethalityRegionalSaude]"
#letalidade por estado letalidadeRegionalSaude = [] for i in range(len(regional_saude)): letalidadeRegionalSaude.append(regional_saude.obitosNovos[i] * 100 /…
-
-1
votes2
answers131
viewsHow to restart the loop for the player to play more than once regardless of whether to hit the answer or not
import random print('='*20) print('JOGO DA FORCA') print('='*20) print('Bem vindo ao Jogo da Forca! Vamos começar!') nome = input("Digite o seu nome:…
-
-1
votes2
answers3029
viewsPython: print(...{}' .format) or print(...+str(...))
code version 1 tempF = input('Temperature in degrees Farenheit: ') tempC = (5 * (int(tempF) - 32) / 9) print('Temperature in degrees Celsius: ' + str(tempC)) In the above code (#1), to display the…
-
-1
votes2
answers54
viewsSeparate extension name - in Python
I have a column in the spreadsheet in Excel with the following column: Atendido por Ismael (100) JEFFERSON LUIZ ESTEVAO DE MOURA (111) Felipe Braga Regis Souza (222) I have to take just the name and…