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
votes2
answers45
viewsValue Replace with Python and Pandas
Hello, I’m trying to remove a character from a base that I extracted from a TXT file, I loaded the file with pandas but I can’t remove it using replace command, below the values I have in a certain…
-
0
votes1
answer60
viewsProblem when trying to solve a challenge
Good night, you guys... I need your help to write a small code that is able to receive a number as well as its index and return the next element of the sequence... The problem is that I still can’t…
-
0
votes1
answer32
viewsCalculating difference between first and last line in a dataframe pandas
I have a pandas dataframe with five rows 3 three columns. I want to create a function where my code returns columns where the last row is larger than the first row. In the example of my code I want…
-
0
votes2
answers456
viewsPrint data from a list that is inside a dictionary - Python
Consider the following data set: Name + (N1, N2, N3, N4). Name represents a student’s name and should be used as a key. N1, N2, N3, N4 represent that student’s test scores. Use a dictionary…
-
0
votes0
answers55
viewsI’m failing to change the display of the impact field from numerical to a special character
from bs4 import BeautifulSoup import requests import time headers = requests.utils.default_headers() headers.update({'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:79.0) Gecko/20100101…
-
0
votes1
answer171
viewsPython - consume loop api for paging
Currently I consume data from a paginated api using python. I put a number of pages x, the problem is when there are more pages, or when there are fewer pages and you keep looping unnecessarily.…
-
0
votes1
answer33
viewsConnect a lineEdit to a class method
am having a problem giving the following message "Typeerror: query'" I have a project that so far works well in structured paradigm, but I’m trying to rewrite the code in POO. I have the following…
-
0
votes1
answer100
viewsSelecting a column from a conditional loop in a pandas dataframe
I have a pandas dataframe with five rows 3 three columns. I want to create a function where my code returns which columns the value of the last row is greater than the first row. In the example of…
-
0
votes0
answers23
viewsHow to handle 2 installed Pythons (e.g. python installed in Miniconda vs python installed in Windowsapps)
I usually use python through Miniconda, but due to some projects I had to download Node.js directly from the site (without using the Agreement for this) and it installs the latest version of python…
-
0
votes1
answer51
viewsIncorrect value of Agg Mean
I need to get the same result of the media, fashion and average of this table Televisores/dia Freq. absoluta 0 |----- 20 5 20|----- 40 25 40|----- 60 40 60|----- 80 15 80|----- 100 10 100|----- 120…
-
0
votes0
answers24
viewsString concatenation from variables in the execute method of sqlite3 in python
I am trying to insert data into a table created in Python (module sqlite3) indirectly, that is, through variables that receive the values of inputs and not directly by typing them into the string of…
-
0
votes1
answer94
viewsHow to import CSV files from a same level folder (and/or above) in Python?
I have already searched several topics here, unsuccessfully however. So, if there is already an equal question, please forgive me and indicate a solution. My project is articulated as follows:…
-
0
votes2
answers28
viewsHow to do procedure in Pyhton Jupyter lab with a number list and not just with a list item
I’m trying to do the procedure below but x and y are a list of numbers and that’s why it’s giving error. I used the following code: theta = [180* math.atan(y/x)/math.pi for x,y in zip(media_v1,…
pythonasked 3 years, 8 months ago user219748 -
0
votes0
answers42
viewsHow to make functions available in the "Python/C API"?
hello I am developing a python module and I have the following problem. When the module is compiled, only one function is available (fun1). how do I get fun2 stay available too? #define…
-
0
votes0
answers28
viewsMouse placement in the center of a rectangle with pygame.mouse.get_pos()
Hello! I read the following code with Pygame: import pygame PRETO = (0,0,0) AMARELO = (255,255,0) VERMELHO = (255,0,0) VERDE = (0,255,0) AZUL = (0,0,255) BRANCO = (255,255,255) LARGURAJANELA = 500…
-
0
votes1
answer172
viewsHow to sort a dictionary list alphabetically and generate new dictionaries with if condition with Python?
Good night, I have a Python exercise that has stopped me, it is the following: Read and store in a dictionary the name, age and phone number of your contacts, the key being the name. When typing an…
pythonasked 3 years, 8 months ago Marcos Prado 19 -
0
votes1
answer28
viewsHow to treat a function value as an existing variable?
I’m making a simple game, just to test the Pygame library. It turns out that as in the game I would have several objects I found it more feasible to create a function to move them: def…
-
0
votes1
answer42
viewsDraw things in pygame
I’m reading a python book had a code I can’t understand: my doubt Doubts: 1.What is this get_rect() ? 2.How does it work to treat things like rectangle ? 3.What is self.screen_rect =…
-
0
votes0
answers12
viewsChange xx axis in Python
Good afternoon. I’m trying to create a graph in Python, but I wanted to separate the lines and the dots on the left and right so that you can see these dots and not get too close together. How could…
-
0
votes0
answers21
viewsHow to add bookmarks to a Google contact via People API?
I am adding contacts via People API with the following code: SCOPES = ['https://www.googleapis.com/auth/contacts'] def start_service(): creds = None if os.path.exists('token.pickle'): with…
-
0
votes1
answer55
viewsHow to assign a function to a kivy button?
I am a beginner in python and I want that whenever a certain button is pressed, run a function. Here is the code: application py. import kivy kivy.require("1.8.0") from kivy.app import App class…
-
0
votes1
answer24
viewsEmpty table ("Empty Dataframe") and ambiguity of comparison in Pandas
Hello, I’ve been trying for a few days to set up a program, the bulk of it is working but there are two demands that do not come true at all. who are they: Amount and total amount of tests involving…
-
0
votes1
answer46
viewsHow to reach a dropdown element through partial text in Selenium - python
How can I select an element from a dropdown through part of its name? I want to select an option based on values taken from a database, but these values do not have the full name of the elements of…
-
0
votes2
answers55
viewsPython: Run class or element inside a class
there is some way to execute a def that is within a class or some other element that I do not know about without the need to include the () of the class, only with the name? See the example below of…
-
0
votes1
answer200
viewsCreate a contact list and separate it into two other lists
I have to create a list of contacts in Python, with name, age and phone number, and then I have to separate in 2 lists: a list only with contacts over 18 years old and another list only under 18…
-
0
votes0
answers24
viewsCount and length in Texas
Hello, everybody. I have a Django project and one of its features is to generate statistical numbers. For example: I have an employee model and it has boolean fields, like, whether it is active or…
-
0
votes1
answer86
viewsHow do I lower a csv file of 3 GB, to be able to import in pandas in google colab?
In the colab a mistake: "Session failed after using all available RAM. If you have interest in accessing execution environments with more RAM, check out Colab Pro." I wanted to decrease the csv file…
-
0
votes0
answers8
viewsError when concatenating distinct CNN branches/models
I’m trying to implement a 3D facial recognition algorithm using convolution neural networks (CNN). I implemented a Generator image for rgb images and a Generator image for in-depth images…
-
0
votes1
answer35
viewsStore values obtained by calculating the distance of points in a matrix
I’m taking my first steps python and I want to store a series of values I got in calculating the distance between points in a matrix NxN to then select the values of each line and establish a limit…
pythonasked 3 years, 7 months ago Guilhermino 11 -
0
votes2
answers392
viewsI need to join several excel files in a single split into python folders. I did this method but wanted to create a function:
I made this function that receives the destination directory and the month that was generated the reports, I wanted to make it smaller using a for that goes through this list: ufv_name = ['CB1',…
-
0
votes0
answers20
viewsXPATH span within div
I’m trying to get data from the site: Thing Verse, but I don’t succeed. I tried to put the html code here, but it would be too big... Anyway I search for the Xpath and find the elements I want to…
-
0
votes1
answer22
viewsUsing Loginrequiredmixin with Login Formview
Basically, I have a Formview where I do validations to log users to my platform, if the result is positive, it is redirected to the URL /dashboard/, as shown in the code below. class…
-
0
votes0
answers13
viewsnp.savetxt downloads a format file ... (formatting problem)
I am editing a code that groups some values from HTML Donwloads and stores them in a list called column_b. Along with column_a (a list of values already defined), I want to do a csv and download it.…
-
0
votes1
answer51
viewsSqlite database conflict when merging into git
I’m working with someone else on a Django project and she owns the main repository. I have a Fork from this repository and want to update it with the original. I created the upstream: git remote add…
-
0
votes1
answer35
viewsProgram usually runs but has moments that stops in the middle of execution and does not leave the place
This program is to draw numbers for the mega sena. I got the result I wanted, but there are moments that the program stops in the middle or at the beginning of the execution. The user places the…
-
0
votes0
answers19
viewsDjango Favorite view
I’m trying to create a favorite button for an app’s posts, but I can’t figure out how to create one because it contains an entire number. When the user clicks on the favorite button. The button will…
-
0
votes1
answer77
viewsEven if you get it right, the message doesn’t change!
I’m trying to create a game in Tkinter, it’s simple thing, you kick a number and then a message appears if your kick is right or wrong. I already did this in CLI, however, I went to try to make a…
-
0
votes1
answer54
viewsSyntax Error (Phyton)
I am doing a work here with python using Pandas/Matplotlib/Seaborn/Numpy and wanted to understand why it gave syntax error. I’m trying to modify 3 columns of my dataset if String for Date Time.…
-
0
votes1
answer365
viewsExtract specific information from an excel cell using pandas in Python
I need to extract information from a cell in excel using pandas and pyautogui. The cell has a date contained and accurate take out the numbers without the "/" bars. Example: 25/12/2000. What I do at…
-
0
votes1
answer27
viewsPython Django heritage with Unique attribute
I’m in a little trouble. class Pessoa(models.Model): cpf = BRCPFField(**unique=true**) class Aluno(Pessoa): novo_atributo = .... class Instrutor(Aluno): outro_atributo = ... class Gestor(Pessoa):…
-
0
votes2
answers91
viewsAdding a character to a python str
I have a date of birth where I need the program to read the information and enter the day, month and year using pyautogui. For the WRITE function to work, I need to transform the date, which is an…
pythonasked 3 years, 7 months ago G̶e̶r̶a̶l̶d̶o̶ J̶u̶n̶i̶o̶r̶ 17 -
0
votes1
answer64
viewsHow to add values from one model and insert the result into another using Django?
I have this model that aims to register the available services and their respective values: class Servico(models.Model): nome = models.CharField('Nome do serviço', max_length=255) preco =…
-
0
votes1
answer95
viewsRemove Row and Column Indexes in the Dataframe
I’m learning python and I started using pyqt5 as a graphical interface and, to force learning, I’m doing a little contest ball drawing. For data analysis I’m using DataFrame and adding to…
-
0
votes0
answers51
viewsSelect - Dropdown menu option not selected - Python Selenium
Hello, I’m doing a Python project using Selenium. When you select to choose an option from a dropdown menu, it is not selected. I’ve always done it this way and it’s always worked and I wonder if…
-
0
votes0
answers19
viewsHow to make a number with reset Random when restarting the program in python?
I created this system to generate a random number but I cannot reset the generated number every time the user selects play again, what would be the easiest way to solve this? import random…
-
0
votes0
answers162
viewsWhat is the input(). split(" ") for in python?
I’m solving some exercises in python and when I put the code this way: A = float(input("")) B = float(input("")) C = float(input("")) triangulo = float((A*C)/2) circulo = float(3.14159*(C**2))…
-
0
votes0
answers12
viewsReturn data with CBV using parameters in the Django url
Good evening. I am trying to return the data of a query, and even managed to make the query work. The problem is when to send the data to the template. Always appears the error that has to be a…
python django url framework django-generic-viewsasked 3 years, 7 months ago Sergio Sacchetti Junior 55 -
0
votes1
answer180
viewsurllib.error.Httperror: HTTP Error 404: Not Found
I have the following code, simple. from urllib.request import urlopen from bs4 import BeautifulSoup word_site =…
-
0
votes1
answer48
viewsGood evening I made a poll/poll code, but it’s not computing the vote when it’s said by name instead of number
I made a line of code to do a search on a street to find out which channel people watch, and I put it to compute the vote by channel number or channel name, but it only computes the votes made by…
-
0
votes1
answer39
viewsHow to run widgets that use Qtimer from a different Thread?
I created an application where the user presses a certain key combination - using the package pynput - and a message from a "Qtoaster" appears on screen. Below is an example code: from pynput import…