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
-
0
votes1
answer167
viewsWebdriver not error but also does not open the browser
I tested a simple code to make the webdriver open Chrome, and was successfully executed, but the code below not error, but does not open the browser. from selenium.webdriver.common.keys import Keys…
-
0
votes1
answer79
viewsBy loading my xlsx file into pandas, the rows have become column indexes. How to set a new input for columns?
I would like to know how to set new index for columns. data = pd.read_excel('numero_automoveis_vendidos.xlsx') data.columns Index([7, 5, 9, 11, 10, 8, '9.1', 6, '8.1', '10.1'], dtype='object')…
-
0
votes1
answer39
viewsRun more than one csv file using python
I have the following question: I read a csv file and in this file I want to take the lines 0:9 and leave the 10 on. I made this code and everything seems to be ok. My problem is: How to read…
-
0
votes2
answers39
viewsDelete string snippet whenever Python repeats
I have a Dataframe that in a given column there are many names and all these names have a type extension: "NAME A_SOJA_2020.xlsx" "NAME B_SOJA_2020.XLSX" I would like to develop a function or code…
-
0
votes2
answers286
viewsHelp in the Python!
I’m stuck in a part of the exercise and I needed someone to shed some light. I’m not sure if I’m doing it the right way but where I’m really doubtful is how to display information in this way:…
-
0
votes1
answer35
viewsmysql Connector problems in python
I’m having trouble connecting to mysql.connector.. In php myadmin, connects normal, and also bash is entering normal in mysql.. Only python gives this problem..…
-
0
votes0
answers41
viewsImproving python-generated table visuals with Django and bootstrap
I have a table that I Gero through the python prettytable, it generates a variable that contains a table, I send this variable to the Jango template and it is all disfigured, could I improve her…
-
0
votes1
answer55
viewsthe program does not read the data that is in the text file
The.txt rain text file contains results of pH analysis of rainwater samples. Each of the lines has (separated by ";") the date of commencement of sampling (in the form YYYY-MM-DD), the duration of…
-
0
votes1
answer543
viewsConfigure HTML table using python’s Django for structure
I’m making a table through 3 lists generated in the views, but I can’t leave the table configured correction in html, would be 3 columns and 60 lines, but they are not adjusted correctly, follow my…
-
0
votes1
answer103
viewsWhy in Python are there functions where the parameter should be placed between parentheses and others should be placed with a dot and the function name?
There are functions that should be written as for example sorted(variavel) and others are written as variavel.sort() I know the differences between the two functions above, I just used to exemplify.…
-
0
votes1
answer293
viewsProblems with win32com
I have the following error in my code, I’ve tried everything and I can’t fix: 1° Attempt - Unsuccessful excel = win32com.client.Dispatch("Excel.Application") wb =…
-
0
votes1
answer53
viewsError with np.random.suffle, result None
I am trying to mix a dataset with 3 columns and then divide it in half for use of one part for training and another for ML testing. I’m using the code: Dataset = np.append (col1, col2, axis = 1)…
-
0
votes1
answer795
viewsMy vscode terminal does not display the result
Good afternoon! I am learning Python in Windows environment and in an example my terminal does not show the desired result. When I run the code through the terminal it opens another window asking…
-
0
votes1
answer60
viewsORA-01461 error when trying to save a CLOB text field generated by a template. What do I do to fix this?
Error trying to save a record in Lotemail class. table: lotemail LOTEMAILID NOT NULL NUMBER(18) LOTEMAILCORPO CLOB Class: class Lotemail(models.Model): lotemailid = models.BigIntegerField(…
-
0
votes1
answer148
viewsStack assignment problems in Python
I’m having a problem with a stack code, is returning the following message: line 9 in empilhar_pilha: novo_numero.proximo = pilha.topo AttributeError: 'float' object has no attribute 'proximo' line…
pythonasked 5 years, 5 months ago user141036 -
0
votes2
answers60
viewsIs there any way to use methods within other python methods?
I wonder if in Python it is possible to create a loop for within a format()? Example #Considerando: z=(1,2,3,4) print(f'''os números pares foram { for i%2==0 in z: print(i,end='são números pares')…
-
0
votes1
answer93
viewsProblem searching and filtering date data on object
I have the following functions to search and sort a user for a certain date, however, when running these functions on an object, it generates an error KeyError: 0 in function listagemData #Criar…
-
0
votes1
answer82
viewsModule named 'Tkinter' not found - python
I started messing around in the library tkinter python recently, but I can’t because the library is not found. The error message shown is as follows: ModuleNotFoundError: No module named 'tkinter'.…
-
0
votes2
answers61
viewsHow could I implement this code so that if I type "a" as 0 the program stops immediately and the message "END" appears?
def conta(x,y,z): return (a**b)+c a = int(input('Infome a: ')) if a == 0: print('FIM') b = int(input('Infome b: ')) c = int(input('Infome c: ')) result =…
pythonasked 4 years, 3 months ago Marcelo Carvalho 13 -
0
votes1
answer2511
viewsHow to loop a dataframe by conditionally removing lines and restarting the loop in a recalculated dataframe at each removal?
Hello, I am performing some data processing and I need my algorithm to perform the comparison between two lines and remove the worst one, according to some conditions. Each time the algorithm…
-
0
votes2
answers63
viewsEdit date value within a dataframe
I have this Dataframe and the date is in the following format: '2020-08-01' I would like to write a loop that iterates on each line and performs the switch to the following format: '01/08' I’m using…
-
0
votes0
answers52
viewsProblem when recording data
I’m performing a query on a table where the structure is : Documento Produto 123 Camisa Posh rosa 127 Calça Handara 36 127 Meia Barby 158 Calça Handara 38 129 Blusa Yoll M 129 Blusa Yoll azul P 129…
-
0
votes0
answers166
viewsObtaining and formatting cookies from a request
Guys, in PHP I used so: preg_match_all('/Set-Cookie:\s([^\;]+)/mi', $response, $matches) I took a look at the documentation and tried to follow this line of logic but it doesn’t work: I’m an amateur…
-
0
votes1
answer67
viewsGlobal variable does not change the value
I’m a beginner and I don’t know why this code doesn’t work. Can someone tell me why? def teste(): global res1 res1 = input().strip() if res1 == '1': print('funciona')…
-
0
votes1
answer146
viewsArithmetic calculations (sum) in the Flask-Sqlalchemy database
I have a table in my database that the user places the total flight hours he has done. I wanted to know how to add all the hours of the user who is in the database and show in templates. Backend:…
-
0
votes1
answer637
viewsPython: listbox with multiple columns in Tkinter - sort columns by clicking on them
I have a listbox with multiple columns, as shown below. I would like to sort the columns by clicking on the titles of them, see the code: I had thought within the "sortby()" function to identify…
-
0
votes0
answers245
viewserror [Errno 2] No such file or directory
For some reason I haven’t been able to identify the python is unable to locate the path. for profile in sorted(profile_ids): path = '/FileStore/tables/' filename = 'google_analytics_data_%s_1.csv'…
-
0
votes2
answers106
viewsHow to check if a certain value of a column is equal and does not save this value in file?
Good afternoon! I’ve been in a jam for days because I can’t seem to make sense of the problem I’m having. I’m making a query to record data in a type str in python. This query goes through the query…
-
0
votes1
answer531
viewsPython graph does not show all values on the x-axis
I used the pandas library to read a csv file and create a graph using matplotlib: import pandas as pd import matplotlib.pyplot as plt brazil_dataset = pd.read_csv('/content/states.csv') fig, ax =…
-
0
votes1
answer75
viewsProblem with checking existing person in Python chained queue
My code is in trouble verify the existence of the name of a person already on the list, when I enter the person on the list works perfectly, when I search by name when the list is empty works…
pythonasked 5 years, 5 months ago user141036 -
0
votes5
answers115
viewsBrowse lists of different sizes
I am going through two lists and performing an operation, but when the smaller list is over or is over and the operation is not 100% completed. How do I make it so that when the shortest list is…
pythonasked 4 years, 2 months ago Lucas Martins 1 -
0
votes1
answer492
viewsAttributeerror: 'Nonetype' Object has no attribute 'Insert' - Trying to insert a column
Good morning ! I’m new in python and I’m trying to build a script that deletes some lines and includes a column in a dataframe only that for some reason I can’t understand it returns this error.…
-
0
votes2
answers151
viewsCalling a service . py inside another . py
Good afternoon, you guys! I researched a lot on the internet and did not succeed, I have the following problem to solve: I have 3 Python services installed on Windows(example1.py / example2.py /…
-
0
votes0
answers53
viewspgpy decrypt files
I’m trying to decrypt a gpg file with the pgpy library in python 3.7, but I can’t get the Output file of the description, follow the code: import pgpy efile = pgpy.PGPMessage.from_file('Path do…
pythonasked 4 years, 2 months ago Abinael Moura Martins 1 -
0
votes2
answers73
viewsHow to compare snippets of two columns of a Dataframe to generate filter
I have a data frame with multiple columns. I need to filter based on two if the end of the string is the same as the other. p. example: Item 1 Item 2 Item 3 carro do joão quitado casa do joão carro…
-
0
votes3
answers141
viewsAmounts of games in a betting code and their random numbers in ascending order in Python
The lottery draw code produces 6 random dozens and would like to know how to keep these numbers in ascending order, besides define the amount of games the user wants to be generated. # Como que o…
pythonasked 5 years, 5 months ago user141036 -
0
votes1
answer72
viewsUnicodedecorror in "Pip upgrade" and "install pywinusb"
My experience in Python is not much, but no error of this kind had yet appeared in any installation. As always appeared the message to upgrade the version of Pip, I decided to continue with this…
-
0
votes2
answers195
viewsRecursiveness using Python
I am trying to create a recursive function that takes a positive integer number N and prints all even numbers from 0 to N in ascending order. I’m only managing to do the opposite, that is, print the…
-
0
votes0
answers35
viewsError compiling with buildozer
Look, I’m having a problem with buildozer, I’m using zbarcam that’s worked on top of cv2 and pyzbar right? So when I go to compile from a module error, then I add the name of the module in the…
pythonasked 4 years, 2 months ago Game Hacker 1 -
0
votes0
answers383
viewsDataframe: Empty 'Dataframe': no Numeric data to Plot
I’m trying to get the highest values in the column Valor Pago. No Jupyter. top_10_empenho = portal[['Descrição', 'Valor Pago']].head(10).set_index('Descrição').sort_values('Valor Pago',…
-
0
votes1
answer86
viewsMatrix input reading in python
I’m wondering how to create an array in python, but the input would be the whole matrix. I tried to make: matrix=[] for r in range(5): row=[] for c in range(5): row.append(input().split())…
-
0
votes1
answer48
viewsFunction returning None, when if or Else runs
How do I make the following function not return None? def dif(x, z): if x != z: print('\nNúmeros diferentes') return else: print('\nNúmeros iguais') return n1 = int(input('Um número: ')) n2 =…
-
0
votes1
answer298
viewsImport images from a Python folder in the same format as MNIST
I need to do a Python facial recognition algorithm using Neural Networks. My advisor told me to use Keras and analyse that application in which the dataset Mnist: Application code (taken from…
-
0
votes1
answer112
viewsRun Python files using python
Is there any way to run an x file in Python using a y file in Python, through Python codes?
pythonasked 4 years, 2 months ago Gustavo Luzsa 11 -
0
votes1
answer81
viewsDelete a range of values in python
I have a code that eliminates values as needed, but I’m not able to put an interval to delete or keep the value. For example, I want values between 7:00 and 5:00. If you put values greater than 18h,…
-
0
votes1
answer255
viewsGenerate Python CSV from txt
I’m trying to run the code: import csv listaG = [] arquivoSaida = 'teste.csv' with open('Arquivos_avanco.txt', newline='') as csvfile: spamreader = csv.reader(csvfile, delimiter='-', quotechar='|')…
-
0
votes2
answers1552
viewsHow to show an image on Tkinter?
I want to add an image to the widget, but nothing appears, I tried to follow the same face https://stackoverflow.com/questions/28139637/how-can-i-display-an-image-using-pillow , but it doesn’t work.…
-
0
votes1
answer33
viewsHow do I click a button if a specific target is there?
Depending on the CNPJ I carry, it generates a new anchor, with a different ID, then I need to click this <a id="menuPrincipal_divLinks3" title="" href="../Relatorio/GerarRelatorio.asp"…
-
0
votes2
answers322
viewsSwitch from insertion mode to typing cursor mode?
When I open a new file in Pycharm the cursor is as if I had clicked on the Insert key, someone knows how to solve?
-
0
votes3
answers75
viewsWhy is my code "swallowing" string on a list?
letras = ["A", "B", "C", "B"] vogais = ["a", "e", "i", "o", "u"] for letra in letras: if letra.lower() in vogais: print(letra.upper()) letras.remove(letra) elif letra.lower() not in vogais:…