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
answer851
viewsPython pandas formatting
import numpy as np import pandas as pd ID = [i for i in range(1,101)] def tabela(imc): if imc < 18.5: return 'Abaixo do peso' elif imc < 25 and imc >= 18.5: return 'Saudável' elif imc <…
-
1
votes1
answer51
viewsDoubt beginner ! Manipulating series
I’m doing my first analysis with Pandas in Python 3. I’m practicing with a game of Thrones dataset that contains the deaths in the books. One of the columns of the dataframe refers to the house and…
-
1
votes0
answers60
viewsHow can I use the Opencl functions available in Opencv?
I am creating a program in Python, which often ends up demanding more from the CPU and decided to research on how to use the GPU for processing. The Opencl databases I found had examples only in…
-
1
votes1
answer143
viewsNumpy Array Error With dtype=numpy.uint8
The code below works normally, however the elements are "objects". M = numpy.array([[1,2,3],[1,2],[1,2,3,4]],dtype=object) However, when executing the code below, I receive the message "Setting an…
-
1
votes2
answers1540
viewsTransforming vectors into a Matrix
I have several signals, where S1, s2 until Sn, are vectors of size n, I would like to unite them in a matrix to stay as follows: matriz = ( [s1] [s2] ... [sn] ) So that I can access an element at…
-
1
votes1
answer98
viewsWhat signal to use for firing methods from a pygtk thread?
I have a Tree View that I need popular with data obtained in a thread, but if I do it from it the program presents several random problems and errors. Researching found that the ideal is to trigger…
-
1
votes2
answers1715
viewspython list problems
I’m trying to solve this problem in python: Make a program that loads a list with the models of five cars (example of models: FUSCA, GOL, VECTRA etc). Upload another list with the consumption of…
-
1
votes1
answer648
viewsHow to use Python Chatterbot in HTML page?
I’m developing a Chatbot in python, using the Chatterbot library. I wonder how I can "embed" this chatbot into an HTML page. I’m a beginner. Using USB Web Server Follows the code: # -*- coding:…
-
1
votes3
answers559
viewsPython - Find numbers larger than average
I’m having trouble with the following question: Write a python function that you receive as parameter a real tuple. The function should return the average and the amount of values greater than the…
pythonasked 6 years, 6 months ago Thiago Andrade HoocKPeeR 29 -
1
votes1
answer2812
viewsConfigurations environment timezones Django postgres linux
Good morning to all. I have a website (Django) in a Linux hosting service with SQL Postgre bank that is in New Jersey (USA). Users are in Brazil, therefore I have a difference of Timezone. I’m sure…
-
1
votes1
answer1949
viewsProgram a Python function to always run on the last Friday of the month
The code below demonstrates an example of how to program, but is somewhat limited to minutes, hours and days. I need one that also includes the month and the specific day, which in my case is…
-
1
votes1
answer85
viewsHow to declare and use methods that are in the same class
Good afternoon. I would like to know how the declaration is made and the use of methods within the same class. For example, in one class there are 2 methods, which 1 method uses the other. For…
pythonasked 6 years, 6 months ago Rodrigo Saito 88 -
1
votes1
answer2280
viewsChange colors in program using Tkinter
hello, I need to create a function or maybe two to change the background color of the main window without interfering with subsequent events. wanted to add in the menu feramentas>environment:…
-
1
votes1
answer1071
viewsHow to create a dictionary and auto increment values?
I need to create a dictionary from a list of integers, where each key contains the value of the sums that are in the list: t = [[1,2],[2,1],[3,1],[4,1],[1,1],[2,2],[1,2]] dicionario = {} for i in t:…
-
1
votes1
answer216
viewsSort 2D vector in descending order
I have the following vector: a = [['UK', 'FR', **numero**], ['UK', 'NL', **numero**], ['UK', 'PT', **numero**]] Where the variable number are floating point values and different. Wish to sort vector…
-
1
votes1
answer411
viewsimporting data extension ". date"
My Python code is loading a dataset from the internet, but the same is not recognizing the columnar number of the data. Python code: import pandas as pd ##Importando dados data =…
-
1
votes1
answer143
viewsI cannot return assigned values to variables
I am layman programming myself and decided to start a program in python to use as a tool in a game well, the code so far is this: def tempo (temp): total=temp*quant dias=total//(24*60*60)…
-
1
votes1
answer82
viewsCan someone please explain some of that code to me?
The code in question is the bottom one, a lot of it I’m understanding more the loop for confused me, it gets the sequence of the variable, but in print, it informs exactly the sequence that the user…
-
1
votes1
answer130
viewsHow to open a csv created in Python without opening an import screen?
I have created a Python csv in several ways as can be seen below, but every time I open the file opens the import screen as below. Why does this happen? And how can I make the file open directly,…
-
1
votes0
answers67
viewsPython Invalidargumenterror: You must feed a value for placeholder tensor 'y' with dtype float and Shape [?,10]
Hello I’m using a CNN network for street view house Numbers SVHN data. When I try to run my code below to be able to generate a summary that can be read by Tensorboard through graphs, the following…
-
1
votes2
answers408
viewsHow to make 9 potentials quickly
I’m asking a question that asks to raise the number to 9 and say the last digit I got, but the resolution seems to have passed the time because it had number 10 9, how to solve it more quickly My…
-
1
votes1
answer388
viewsProblem when installing Numpy
Good morning guys, I was trying to install Numpy in this machine... I ran the command "Conda install numpy" ai worked...but when I ran "Pip install numpy", it returns this error.…
-
1
votes1
answer6608
viewsAdd column to a dataframe based on the classification made on another dataframe
Greetings! I have two dataframes. Both have columns that determine intervals, with maximum and minimum numbers. In each dataframe the classification of each range is done in one way. I wanted to…
-
1
votes2
answers329
viewsPython: conditions for various symbols
I have a doubt, I remember having seen somewhere the resolution but I’m not finding more. So the problem has several symbols for example simbolos = ('!','?',',','\'') here it is like tuple which is…
pythonasked 6 years, 6 months ago Patrick Amaral 88 -
1
votes1
answer282
viewsGet request in Python terminates the program when there is no connection
I am developing a Python application to check the external IP and save in a database, the problem is the following function: def pega_ip(): ip = get('https://api.ipify.org').text return ip Because…
pythonasked 6 years, 10 months ago Luis Fernando Consulo Martins 89 -
1
votes1
answer145
viewsWhat is the difference between these forms of command execution?
These commands in Python: lista = eval('[' + input("Digite sua lista: ") + ']') And this: lista = input("Digite sua lista: ") And this: lista = [int(x) for x in input().strip()] Why the latter gives…
-
1
votes1
answer225
viewsText editor geany
I am using geany for python programming and need to change the background color of the text editor, I am using it in debian someone knows how to do?…
-
1
votes1
answer5446
viewsPython 3 import of classes
I have three . py files in my directory: Banco.py, app.py, Usuarios.py. My app.py contains the Tkinder import that I am using in the code and here I start all my view and in it I import the class…
-
1
votes1
answer3520
viewsSave text file in Python
I am creating a simple text editor with Python and Tkinter and I want to do a function to save what was typed. I made the save function, but it only creates the txt file and does not save what was…
-
1
votes1
answer139
viewsPython-Mainloop Does not work
I need some help, I’m starting now and I’m getting kkk, The situation is as follows: I’m making a simple screen, but the mainloop function does not work. If I use the terminal and use class creates…
-
1
votes2
answers7328
viewsLimiting the number of characters in a Python string
Guys, I have a Python script that during the processing of information is generating string with many characters and I need each string to create a folder with its "name". But don’t get caught in…
pythonasked 6 years, 6 months ago Edeson Bizerril 661 -
1
votes1
answer73
viewsWhy is the source not changed in Raspberry Pi?
I have a graphical application using Gtk in Python, the program has font definitions and font sizes. When running the program on linux works correctly, but when running on Raspberry the source is…
-
1
votes3
answers1588
viewsPython Floating Point Problem 3
I’m writing an algorithm where variable increment float in 0.2, however, after a few increments instead of incrementing 2.2 for 2.4, for example, the program increments to 2.4000000000000004 I’ve…
-
1
votes2
answers1096
viewsError formatting string for python datetime
I am trying to format a string with the format "2018-05-09T05:05:34Z" for "09/05/2018" but is given the error ValueError: unconverted data remains If I use: dataAntiga = "2018-05-09T05:05:34Z"…
-
1
votes1
answer2169
viewsPYTHON - How to know if there is an object on the screen from a reference?
Basically I wanted to know if there is the possibility of knowing if there is an object on the screen from a reference Example: There is a generic program on the screen that displays a closed lock,…
-
1
votes2
answers174
viewsDoubt when ranking using Jango!
I’m making a site of a game using Jango and I want to make a ranking based on the score of all users! For now it’s like this: py views.: def index(request): perfis =…
-
1
votes1
answer102
viewsHow to add methods to a Queryset?
I have a model defined in Django. I would like to add to this model a method that returns me part of a mounted query (a Queryset). That is, a method I want to define a method that affects the…
-
1
votes3
answers1839
viewsWeb scraping python running javascript on the CEF website
The CEF (Caixa Econômica Federal) changed the way it displays the results of the lotteries on its website, before I could get the results that all came in HTML via webscraping relatively easily…
-
1
votes3
answers213
viewsColoring line background(Row) on Django admin
I have a code that is working, but not totally with what I want, it is coloring only the selected cell, I want to color the whole line depending on the status of the column.. follows the code:…
-
1
votes0
answers81
viewsWhat better way to parallelize this function?
I am trying to parallelize a function that calculates the Cosine similarity: Here is my code: import numpy as np def cos_sim(a,b): dot_product = np.dot(a,b) norm_a = np.linalg.norm(a) norm_b =…
-
1
votes1
answer168
viewsPython: Cleaning html code
Using python, what would be the easy way to clear tag parameters coming from microsoft tools? Initially I’m trying to transform via Beautiful Soup, but I’m open to all suggestions! :D In this way:…
-
1
votes1
answer617
viewsDoes query with date in sql include the day in question?
I have a doubt in a matter of the exact days that SQL include, and my system once a day performs the following query on the system: SELECT id,nome FROM products WHERE created_date between…
-
1
votes2
answers1389
viewsFetch a value within an array of dictionaries
Hello, I’m doing the following in python: I created an array of dictionaries and would like to search within this array if a given word exists. Ex: palavra1 = {'palavra': 'sim', 'positivo': 0}…
pythonasked 6 years, 5 months ago Gabriel Augusto 530 -
1
votes1
answer842
viewsPython, display index of a specific row within the matrix
Dear Gentlemen(as), You could give me a hand. An idea?! --> I am trying to present (print) the index(the line) of the longest interval between the longest and shortest of the rows of a matrix…
-
1
votes0
answers1200
viewsHow to finish process 'Chrome.exe' when finishing script execution
I implemented a script using Selenium that accesses some pages. The code is working exactly as expected. My problem is when script finishes its execution which happens in two ways: When the user…
-
1
votes3
answers416
viewsHow to Insert in a non-zero position in an empty list?
How can I insert a value in a non-zero position into an empty list? Ex: lista = [] . . . lista.insert(3, 'valor')
-
1
votes1
answer331
viewsProblem in Django’s send_email function
Good afternoon! I have the following code in views.py: def email(request): if request.method=='POST': form = ContactForm(request.POST) form.email = request.POST.get('email', '') form.subject =…
-
1
votes2
answers872
viewsHow to know how many numbers in one list are repeated in others?
I have four lists of their values: A = [1,2,3,4,5,6,7,8,9,10] B = [1,2,3] C = [4,5,6] D = [7,8,9,10] Would it have any function to compare list A with the other three lists and tell how many numbers…
-
1
votes1
answer2179
viewsAutomate printing of files within a folder
I need to make any file that is in the folder, example c://imprimir automatically printed, check if you have something and send it to standard printer. I’ve been searching in Python but I was able…
-
1
votes2
answers43
viewsDoubt in the logic of the script
Guys, I was wondering why the number 2 is not the first to be printed in this script, I’m not getting the logic. altura = 5 linha = 1 while linha <= altura: print ('1', end = '') coluna = 2 while…