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
votes0
answers150
viewsHow to solve the "Exceeded Time Limit" in this code?
Input format : The input consists of a series of pairs of integers i and j, a pair of integers per line. All integers will be less than 1,000,000 and greater than 0. Note that the entry only ends…
-
0
votes0
answers21
viewsFix the speed of Video Screen_recorder.py
Hello, I’m doing a small project to better understand how screen recordings work. I am making a program in Python, which is working perfectly, however, at the time of running the video, the speed is…
-
0
votes1
answer308
viewsHow to create a condition for each dataframe subset in pandas?
I wrote the following in order to create a condition for a subset of a dataframe in which case the cell value is higher than the average of that same subset(in this case the initial subset is small…
-
0
votes1
answer694
viewsPython - Dataframe - Create a new Dataframe from comparing two other Dataframe
I have a question, and I’d like your help. I have two Dataframe and I need to compare if some columns of these Dataframe are the same and, if they are the same, then I need to store this record in…
-
0
votes2
answers489
viewsCompare two Dataframe and create a new Dataframe
I have a question and would like your help. I have two Dataframe and I need to compare some columns of these Dataframe are equal and, if they are equal, then I need to store the records in another…
-
0
votes1
answer41
viewsProblems with append incremetando until the infinity in Python
I’m doing a program that scans 35 bits on a piece of equipment, storing reference bits in an array. The logic to know if any bit has changed since the last reading, always saves the previous result…
-
0
votes1
answer31
viewsFlickrapi and photos of a specific user with Python
Hey, guys, all right? I need to get some pictures of a specific FLICKR user and with a specific description for a college job. I’m still learning how to program, so I don’t really know how to do it,…
-
0
votes1
answer66
viewsI can’t get the variables I created recognized when using Def
I wrote the code below which is a rectangle triangle calculator using def to define my custom functions. def pedir_base(): while True: try: base = float(input('Digite o valor da base do triângulo…
pythonasked 4 years, 1 month ago Matheus Esteves 61 -
0
votes0
answers77
viewsOpencv with Python error occurs "Assertion failed"
I recently started working with Opencv in Python. Well, I’m making a code here and, when compiling, gives the following error: Ocorreu uma exceção: error OpenCV(4.4.0)…
-
0
votes1
answer102
viewsEvent.key does not work
So I’m trying to make the screen stay fullscreen in the pygame, only event.key doesn’t work. Follow the error: Traceback (most recent call last): File "C:/Users/Ailtinho/Desktop/Scirpts-Python/Jogo…
-
0
votes0
answers45
viewsRemoving Existing Excel Connections with Python
I need help to remove the Excel connection, where I have an SQL query inside Excel that feeds several tabs that are inside Excel, but when I use the code below returns me with an error conn.Delete()…
-
0
votes0
answers55
viewsHow to stop a for inside a while (Python)
I’m doing a facial recognition so I’m using a while to process the video and inside the while has 3 for and inside one of them where I left a comment "#STOP HERE" and where I need a stop because…
-
0
votes1
answer327
viewsNameerror: name 'pytesseract' is not defined
I am using the Pytesseract and Opencv libraries to print a text from an image, but when trying to run the script it gives the following error: img_text = pytesseract.image_to_string(img)…
-
0
votes0
answers204
viewsUpload files to Sharepoint in a specific folder using Python
I am uploading file from my machine to Sharepoint using python with lib Office-REST-Python-Client, but I can only upload the file to the Sharepoint root and not to a certain folder. Code I’m using…
-
0
votes1
answer70
viewsVariable value is changing automatically
I have a question about assigning values to variables. I created the following code for solving equation systems by the Gauss-Jacobi iterative method: A = np.array([[2., -1.], [1., 2.]]) # Matriz de…
-
0
votes0
answers53
viewsHow to connect to an FTP server using digital SHA certificate
I am trying to connect to an FTP server that uses a SHA certificate (.crt) When I try to open the connection to the server I get a return 230 indicating that I am logged in to the server. Follow…
-
0
votes2
answers104
viewsPython - Declaration of a variable in Try
I am trying to create a menu in Python and I came across a part of mathematical calculations where I would like to insert an error condition if the user inserted a letter in a place where he can…
pythonasked 4 years, 1 month ago Diogo Monteiro 3 -
0
votes1
answer48
viewsHow do you know if the phrase is on the list?
I want the message "Uhul! Your secret friend will love", but the variable present always gives as answer "Try Again", example: in the variable 'personal gifts' I type 'pedro camisa keyboard chair',…
-
0
votes1
answer280
viewsOverride Viewset POST action to save and update data in Django Rest Framework
I am creating an application for stock control and am having the following difficulty. When I enter a [product input] the input quantity must be added to the stock quantity of [product]. There is…
-
0
votes2
answers509
viewsFilter data from a Dataframe pandas by a specific column and the last four dates of a set of dates
I have 2 dataframes in Pandas where: Data Frame A - contains information of the available time of announcements in each program DFTmpDisp sinal cod_programa data tempo_disponivel 0 SP1 XXXX…
-
0
votes0
answers74
viewsFilter combobox according to the list of projects created by each user logged in to Django
I’m new to Jango and I have a lot to learn. I’m developing a system in which the logged-in user registers their requirement, but each requirement is tied to a project that the same user created. As…
-
0
votes1
answer241
viewsError using "find_element" command in python Selenium
I am programming a boot that interacts with a google page (google Meet) for this I am Selenium, but when I use the command find_element in python it gives the following error:…
-
0
votes0
answers35
viewsPythonnet primavera DLL
I am trying to use the pythonnet library to access the spring dll, so far I have been able to open the dll and use some of the basic functions of it, but now I am stuck trying to use the…
pythonasked 4 years, 1 month ago patrick arsenio 1 -
0
votes0
answers23
viewsAES in CTR mode
I’m developing AES in CTR mode for my work, but I’m not getting it to return the right result, both at Encrypt and at Decrypt,. Follow the code: class AESCipher(object): def __init__(self, key): def…
-
0
votes1
answer108
viewsHow to split a string into n equal parts in python 3.8 without using functions?
I want to split a string, in the case of a binary number, to convert into octal and Hex, but I need to divide the inserted number into equal parts, in the case of octal, I would need to divide it 3…
-
0
votes0
answers127
viewsUnicodedecodeerror: 'utf-8' codec can’t Decode byte 0xc3 in position xx: Unexpected end of data
I am unable to open a block-separated CSV file (spaces/tab) in Python. The file has 1.7 million lines and is in UTF-8. From what I searched in the Stack in English it is as if the character '0xc3'…
-
0
votes1
answer203
viewsHow to save requests return and save to . txt or . csv file in Python
I wonder if it is possible to save the return of a request in file . txt or . csv in Python. I need some NIST data and for that I made the following code: import requests from bs4 import…
-
0
votes0
answers56
viewsApply binarization and skeletonize to a python fingerprint
I’m trying to make a digital recognition program in python, in the skeletonization part, the image gets lines, as below: The original image is this: My code: import cv2 as cv import numpy as np from…
-
0
votes0
answers59
viewsHow to make a unit test using Flask and Django
I’m new to python testing using Django and flask. Using the pytest library, how would test implementation of the following methods and what could be tested? If someone could give me a light it would…
-
0
votes0
answers19
viewsHow to change the path of the executable using pywin32?
I have two files: one that is the base and the other the 'main' that makes generate the service in windows; However, when I try to start the service, the path of the executable is like another Does…
-
0
votes1
answer64
viewsHow to create property in a Python object?
How can I create an object with property and add to an object list using python? I have a funtion that expects a return from a list of products, this return is used by other futions and do not want…
-
0
votes0
answers30
viewsShutdown python socket server by pressing CTRL+C
I have a server program using a python socket that has two threads: the Accept thread, responsible for accepting new connections from clients, and the clientThread thread, responsible for handling…
-
0
votes1
answer349
viewsHow to change values of only one column in an array (PURE Python)
I am doing a work of programming in PURE Python (that is, it is not allowed to use Pandas/Numpy) whose first part is, in an array, replace certain values by certain numbers. For example: in the…
pythonasked 4 years ago André Filipe da Conceição 3 -
0
votes1
answer351
viewspass the value of a python variable to a mysql search
I’m on a quest and I still can’t solve it. Here’s the thing: def main(): chave = [valores_lidos] while(chave!=-1): vetor = valores_lidos chave= int(input("Informe o numero de id da vaca para buscar…
-
0
votes1
answer135
viewsRead certain columns of xls file in Python with XLRD
I am a beginner in language and I am trying to display the contents of a spreadsheet on the front end with Python. With this code I am displaying the result of the columns name, surname, city and…
-
0
votes1
answer60
viewsHow to login with SELECT in a table? Login system Pyside2 sqlite3
I am creating a simple login system, where the user puts the data entered in a table. But in the code when comparing the data, either it ENTERS even with blank spaces or wrong information or it…
-
0
votes1
answer111
viewsPython - Square root estimate
Good, I was here solving an exercise where the program asks the user for a positive number and calculates its square root using: +=(+ã/) / is an estimate for the square root of the number; + is the…
-
0
votes2
answers266
viewsReceive two numbers, add the pairs and multiply the odd
The program should receive two numbers, and then add all pairs between the received range, and multiply all the odd numbers of the received range (including those typed, always). Must be used for or…
-
0
votes1
answer96
viewsIdentify repeated strings in a list
I’m making a program where a user will add stories, he will add the theme, the title and the body of the story, and I put all this into dictionaries and added them into a list. historias =…
pythonasked 4 years ago DanielXavier 3 -
0
votes1
answer74
viewsHow do I access elements of a json that contains multiple keys in python?
I’m practicing learning Apis with HG Finance , but when I filter the information through a FOR , I see that presents an error called KeyError: nome da moeda, But the code runs the same way, I’d like…
-
0
votes1
answer30
viewsHow to include a value in a matrix by separating a digit in each column?
I developed a program that, when informing a value, this value is allocated in all columns of the row, returning me an array like this: array([[0, 0, 0], [233, 233, 233], [0, 0, 0], [0, 0, 0], [0,…
-
0
votes0
answers16
viewsHow to resolve it? Runtimeerror: Images in list must all have the same Dimensions // Lib face_recognition
I had the following error when working with the face_recognition library, when using the code: face1 = face_recognition.load_image_file('face1.jpg') face2 =…
pythonasked 4 years ago Samuel Cruz 33 -
0
votes0
answers48
viewsHow to set the columns in Sklearn’s Onehotencoder?
I’m having a small problem making an ML code for sorting set when using Onehotencoder to perform categorization. I am following a course that used the resource in the following way: dados =…
-
0
votes0
answers38
viewsMongodb query optimization for large collection with large documents
I am using Pymongo with Flask and would like to know how to optimize a query as I am filtering within a large collection (2947 documents) with large documents. This is the structure of the…
-
0
votes2
answers210
viewsHow to convert a value to float and int in python?
Hello, I am trying to convert a received value from a graphical interface to int or float, to make a software that solves the second degree equations. layout = [ [sg.Text('Termo A:'),…
-
0
votes1
answer203
viewsException Treatment does not work when dividing by zero
I need to read a set of values and report the division between them, regardless of whether they are positive or negative. The problem says that if there is a division by zero a message should be…
-
0
votes2
answers285
viewsHow to bring more fields in the Pandas groupby, without necessarily having to use them in the grouping?
Good afternoon, guys. I’m messing with the Pandas library in Python and I’d like to ask you a question, if possible. I have a list of values and need to reduce this list to just one record per date.…
-
0
votes1
answer250
viewsHow to upload file to FTP server in Python?
I have a script that generates a CSV file and saves with the name of the current date. I’m trying to make a script that checks the latest created file and sends it to the FTP server. How can I do…
-
0
votes0
answers41
viewsHow to open a new Window in Pyside2?
I was using a stop function to open the windows in a kind of window manager. At the top of the class I leave the menu = False, and when it becomes True in the function, it is for the window to open,…
-
0
votes0
answers29
viewsHow to access the Python-Shell output outside the function scope
Hello! I’m making an api using Python in the back-end as the python script is all ok! I will receive a sentence in Javascript and through python-shell I will process it in python, until there is a…