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
answer59
viewsHow to print lines in txt from a variable and manipulate this data - Python
Please, friends, I am working on a python script that reads a txt file and from two values that exist in some lines, it prints in a new txt file. In addition, the results need to stay together, that…
-
-1
votes1
answer144
viewsHow to use objects in Django
I have to create models based on the following UML: I actually made the code of Experience that way: class Experiencia(Base): ACADEMICA = 'AC' PROFISSIONAL = 'PR' TIPO_CHOICES = [ (ACADEMICA,…
-
-1
votes1
answer56
viewsHow to modify a token (Spacy - Python)?
The imported libraries: import spacy from spacy.matcher import Matcher The following code adapted from the selected response of this https://stackoverflow.com/questions/62785916/spacy-replace-token…
-
-1
votes2
answers100
viewsSearch between two dates in Django
I have a program where I need to search through GET on Django the data present between two dates (the user will define these dates) Models py. class Data(models.Model): dev =…
-
-1
votes1
answer43
viewsFailure to install pyarrow and fastparquet
Good afternoon, folks, I’m a beginner in python so please be patient. I’m trying to read a file like . parquet, so I looked on the internet how I could read it and saw that I should install pyarrow…
pythonasked 3 years, 9 months ago Beatriz Campos 15 -
-1
votes1
answer38
viewsFunction writing values more than once - Pyqt5
Hello I’m using pyqt5 to create the graphical interface of a supposed clothing store (I’m training), I have the fields to receive the data to register each type of clothing, but when clicking the…
-
-1
votes1
answer47
viewsFetch value of a condition on lines and separate into a new dataset
I have the following dataset I’m trying to create a dataset based on the dataset above. I am trying to search row by row values that are not Nan, export to a new dataset this value linked to column…
-
-1
votes2
answers50
viewsHow to send text via the template via url in Django?
I want to send text to a view through the template. I have two different types of clients that will be processed differently, to take advantage of code I put in one view and the specific part I…
-
-1
votes1
answer74
viewsHow to create a Dataframe in Pandas based on two Features and more the count of one of them?
Good afternoon to everyone, I’m conducting a data analysis project and I’m having difficulty at a specific point. To facilitate understanding, I have a DF with [1000000+ rows x 29 columns]. In this…
-
-1
votes1
answer41
viewsSum pandas columns by row and selecting comparative by Qgrid row
import pandas as pd import seaborn as srn import statistics as sts dataset = pd.read_excel('/content/drive/MyDrive/Data science /BRA 2020.xlsx') dataset.head() dataset = dataset.drop ('League', axis…
-
-1
votes1
answer73
viewsReturn on screen a database information with Python
I have the following code: # Lista dos produtos produtos = {'1':('Dipirona 500mg 10 cp', 2.99), '2':('Paracetamol 500mg 10 cp', 4.7), '3':('Ibuprofeno 600 mg 4 cp ', 5.98), '4':('Dorflex 10 cp',…
-
-1
votes1
answer44
viewsConditional to capture JSON information via Pyhton
If anyone can help me.. I have a Python script that reads a file. json that contains the web services I need to interact with. At first, my json only needed to contain a service and the script works…
-
-1
votes1
answer201
viewsReceive information from Telebot
I’m developing a Telegram bot and part of it is already functional. Now, I need to receive a user input with questions that the system asks so that I can further automate the processes. In the…
-
-1
votes2
answers325
viewsTransforming date object into datetime (year month day) python
I need to transform a date that is format obj in datetime to make a calculation. The column is in this format: 01JUN2020:00:00:01 01OUT2020:00:00:02 01MAI2020:00:00:04 I tried the datetime function,…
-
-1
votes1
answer33
viewsHow do I call the email field from the default table auth_user?? needed to make users register with email, user and password
my Register.html is like this <!DOCTYPE html> <html lang="pt-br"> <head> <meta charset="UTF-8"> <link…
-
-1
votes1
answer57
viewsCreate column based on another dataframe
Good night! I have two dataframes ex8_alunos and ex8_cursos ex8_alunos ex8_cursos I would like to create a column on ex8_alunos calling for CO_UF To power this column I would need to cross-reference…
-
-1
votes2
answers107
viewsHow to filter choices from a field based on choices from another form field in Django?
In Django Admin I have a model who has two fields: Unidade and Localizacao. Where Unidade has a ManyToManyField for Localizacao, as follows below class Unidade(models.): nome =…
javascript python django django-templates django-adminasked 3 years, 8 months ago Leonardo Furtado 144 -
-1
votes1
answer573
viewsUnboundlocalerror: local variable '' referenced before assignment python
I’m having trouble passing the name changed if it comes to a certain value CODE: import threading import time from random import randint def worker(message): f = open('addresses_0.csv', 'r') inicio…
-
-1
votes1
answer73
viewsHow to make the Qt designer lineEdit receive an integer or float with Python
I would like to know how to make a lineEdit of Qt designer receive a value of type integer or float and armezene that value received in a variable, because, I need to do mathematical operations with…
-
-1
votes2
answers79
viewsElement does not respond to Selenium click (Python)
I am recently working with Selenium in Python and facing a problem in my automation: Selenium identifies the element (either by xpath or any other way), but at the moment of clicking, the element…
-
-1
votes1
answer72
viewsRestart Django Python server
Hello! I’m starting in the world of programming, through a book called "Intensive Python Course". One of the book’s projects involves creating a virtual environment to use Django. I was able to…
-
-1
votes1
answer64
viewsRemove words after specific python character
Hello. I need to find a way to standardize the following classes in python db.groupby(["EdLevel"])["EdLevel"].count() Master's degree 11141 Master's degree (M.A., M.S., M.Eng., MBA, etc.) 13112…
-
-1
votes1
answer68
viewsInserting records into the database from a file
I’m trying to enter records into my database, specifically the model Participante from a file .csv, whose format is id, name, Cpf and email. So far what I have in mine views.py is: def…
-
-1
votes2
answers29
viewsError importing Model Django 3.1
Hello, I am trying to import a model to use inside my View and I am having problems, I made a test file to try to import before putting the model in the view. I already registered the app, I already…
-
-1
votes1
answer159
viewsPython dictionary Alphabetical order and duplicate existing dictionary
Personal I am in doubt on how to write on the screen for the user the values of the dictionary without the bracket and in alphabetical order. I am also doubtful on how to make two new dictionaries…
-
-1
votes1
answer49
viewsCHANGING VALUES ON A DATFRAME
Good afternoon. I have a Dataframe with the following head(): Note that in the bmi column there are Nan values, more precisely, there are 201 lines. I want to change this value based on the age…
-
-1
votes1
answer130
viewsHow to store print values in a variable in Python?
I imported data from a table in Google Sheets using Pandas and created a data frame. I renamed your columns and made a for loop to filter between one of these columns, the values below 20, however,…
-
-1
votes1
answer49
viewsHelp with python Tkinter
Good morning, There’s an extra column, but I can’t figure out where the mistake is. follows the code: from tkinter import* from tkinter import messagebox from tkinter import ttk class arquivo: def…
-
-1
votes1
answer76
viewsHow to receive user data and return function value using flask?
I have a project where I would like to apply a python function using user-given information and return the function result to html. I know you normally use javascript for these cases, but my…
-
-1
votes2
answers51
viewsProduct between vectors
The user chooses the number of positions of two vectors and makes the product between them and displays in the list the result, the code I made is below v1 = int(input("Digite a quantidade de…
-
-1
votes1
answer44
viewsHow to create a new column 'ANO_NASCIMENTO' and insert data into it in sequence, considering each row of the column NAME
Hello!! I’m a beginner in Python and I would like to count on your help for the problems below. I have a df with 2 columns. NOME N.CELULAR João Pedro 98 – 9112 1632 Luís Antônio 98 – 8513 4545…
-
-1
votes1
answer31
viewsHow to filter form options by foreign key? - Django Admin
I need to show only objects that have the same foreign key company in Django in the admin view. What I got was to show only the related objects using get_queryset, but in the form fields appear all…
-
-1
votes1
answer53
viewsPrint of the smallest number of a pandas table
Hello, I have a CSV file with 1000 lines and 10 columns, one of the columns shows the age of the people, the minimum male age is 0 and the maximum is 96, but when giving the print the result comes…
-
-1
votes1
answer180
viewsPython with MYSQL - ERROR: 'Nonetype' Object is not subscriptable
I am trying to practice creating a small program with LOGIN SCREEN. This program has access to a MYSQL database and I want to VALIDATE the login data to allow entry. I’m trying to learn on my own…
-
-1
votes1
answer72
viewsCount words in CSV file
I’m trying to read a CSV file and create a list of all the words in the file and how many times it appears. Originally the file was in PDF, but I thought it could be simpler to read in csv. I’m…
-
-1
votes1
answer46
viewsWhy does the list error Object has in the 'checks' attribute occur?
I’m building a program based on a class diagram, and it appears Attributeerror: 'list' Object has no attribute 'checks' when I print the list with the client’s checks class Cheque: def…
-
-1
votes1
answer30
viewsHow to make classes with multi-level functions?
I’m developing a code for the following problem: I have a series of experiments to be done. For each experiment, I have to do different calculations (which I called beta, dynamic and static in the…
-
-1
votes1
answer202
viewsRunning Simple Python Script with Docker on Windows
I am using Windows environment I created a Docker.py where I just put: print ('Hello Docker') that file is in the folder C: python I did a test to run this file using Docker and it didn’t work I…
-
-1
votes3
answers300
viewsHow to use while and if in Python?
Forgive me if it’s a stupid question, but I’m a beginner. I have to use the while condition to finish the program. In this case, the code has to rotate while the weight is different from 0. And, if…
-
-1
votes1
answer116
viewsWhen I open the Python program directly on CMD, it simply closes
When I try to open this program directly on CMD, without opening in CD path -> python file.py, it arrives to open, but when giving enter, it simply closes... I’ve generated an executable too,…
pythonasked 3 years, 7 months ago Leonardo Piolla 3 -
-1
votes1
answer64
viewsOnly get snippets between brackets
In third-party software, a log record is generated with separate information through words that comes within a bracket. Example: [informação1] [informação2] [informação3] The problem is that the…
-
-1
votes1
answer73
viewsHow can I check if a column of a dataframe is contained in a column of another dataframe?
Hello, I have the following question: I have two dataframes and I want to check if the values of one column contain in another column of another dataframe that does not have the same name nor the…
-
-1
votes1
answer18
viewsHow do I run a Docker image and as soon as the process is over save the generated file inside the container to the host computer?
I have a code that should be run in a container. As soon as it runs it will generate a png file. Follow Dockerfile: FROM python:3 COPY . /projeto RUN apt update RUN yes | apt install…
-
-1
votes1
answer34
viewsInterrupt the POST Django
I am developing a customer registration project/ addresses/ products, and now I am doing the inventory part (list which products certain clients hired), and I put to send the customer ID and…
-
-1
votes1
answer77
viewsUpdate label automatically with Tkinter
I would like to take the value 1 and subtract with the value 2 that the user type and update the result label automatically. This way, as the user is typing the result label is already updating. How…
-
-1
votes1
answer26
viewsHow do I make a Boolean field model to accept only 1 true and multiple false values in Django?
An example of a client’s model address: class Address(models.Model): activate = models.BooleanField(null=False, default=False) AddressLine1 = models.CharField(max_length=60, blank=True, null=True)…
-
-1
votes1
answer110
viewsHow to check if an Input Text is "Empty" or not in pySimpleGUI?
Hello, I’m creating a simple code to train both python and pysimplegui, and I’d like to check whether or not the user left the field empty before clicking save, but looking at the library’s…
pythonasked 3 years, 6 months ago Elvis Brandão 1 -
-1
votes1
answer19
viewsIncorrect data being entered in the list widget
After a lot of trying, I managed to make my program that is a box simulator (commercial automation) the possibility to multiply the items (instead of the box register one by one, when it is of the…
-
-1
votes1
answer56
viewsReturn in while - PYTHON loop
I’m starting to learn python now and I’m still lost in the syntax. In the following program I do not know what to do to restart the program, ie, return to the beginning if the user type "yes" or…
-
-1
votes1
answer32
viewsProblems with print in python socket
I’m already hours away trying to solve this error, well... in the python socket I made a program in which the client sends his name and the program picks up the IP and the date and time that he sent…