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
answers64
viewsHow to select methods in a function and add results in a list?
I’m trying with a function of this kind, which is in my main: if __name__ == "__main__": run_experiment(outros_parametros,['LA', 'RF', 'DT', 'ARD', 'PCA']) Cause only a few methods to be selected,…
-
0
votes2
answers187
viewsGo through Array and remove words - Python
I created a list using a text file and I need to remove all words that are less than 3 characters and more than 8. I’m having doubts about how to go through the list and create another list without…
pythonasked 4 years, 8 months ago Rafael Ferreira 11 -
0
votes1
answer89
viewsHow to read an array of arrays and save each array[ ] into a different variable to run function with barplot?
How can I read this array of arrays: [45 32 56 57 44 21 36 35 39 23 24 27 25 26 31 28 29 30 20 22 18 8 19 1 33 2 3 4 0 6 7 9 17 10 11 12 49 55 13 14 15 16 52 46 43 34 41 37 40 5 54 51 53 47 38 42 50…
-
0
votes1
answer74
viewsassembling 3 dataframes
I created the function below that returns me three data frames: def top_share(x, y, z): x['SHARE-N'] = x.SHARE_VALOR y['SHARE-P'] = y.SHARE_VALOR z['SHARE-3C'] = z.SHARE_VALOR x_top = x[['DESC',…
pythonasked 4 years, 7 months ago Viviane Alves Lima 41 -
0
votes0
answers113
viewsCode error (Python, Pandas and Excel)
I made a code to pick the time and day of the week and so picks up the cell of the excel spreadsheet and should inform me, but it is going wrong when picking up, besides on Tuesday (incicaçao ES)…
-
0
votes0
answers115
viewsBottom-up array - Python
I managed to do as the problem asks, with the code below, the only problem is that I can’t get the user to put the coordinates 0,0, only gets column 0 and the line is not 0, gets 1. I want the user…
pythonasked 4 years, 7 months ago Filipe Motta 17 -
0
votes0
answers19
viewsIs it possible to create variables from a counter?
Good afternoon, I wonder if it is possible from the value obtained in a counter, to create variables in the same amount. To illustrate better: counter_persons = 2 person 1 = float(input('Enter your…
pythonasked 4 years, 7 months ago Eduardo Carlos Santos Pereira 41 -
0
votes0
answers219
viewsDjango is not reading the Static statistic files
Well, it was all right until a certain moment. Then I don’t know what happened, or if I put something wrong and nothing else is working. Django stopped reading the static files. When I try to enter…
-
0
votes1
answer74
viewsResult in a Python Dataframe
I have the following code: import numpy as np import pandas as pd import psutil as ps names = [] for service in ps.win_service_iter(): info = service.as_dict() listOf = [("Name:%s; "…
-
0
votes1
answer48
viewsError " Indirect fixture" when using pytest with a python factorial function
I’m studying recursion and automated testing and decided to implement a recursive factorial: def fatorial(n): if n <= 1: return 1 else: return n*fatorial(n - 1) import pytest…
-
0
votes3
answers119
viewsHow do I reset the Flask server using if within the algorithm?
Next, I am creating a game in order to learn, however, I need this game to "reset" when the amount of attempts is reached. At the beginning of the code I have the following: from random import…
-
0
votes1
answer80
viewsAttribute mutator generate Typeerror if it does not receive a number
I’m trying to make a phone error treatment where when it’s set some value other than a number it throws a TypeError. Can someone see if I’m doing it right or where I can adjust? from typing import…
pythonasked 4 years, 7 months ago Ismael Menezes 101 -
0
votes1
answer37
viewsHow to add elements from a file to a dictionary?
Hello, I’m making a program that has to take all the elements of a file (which has several lines) and put in a dictionary like this: file (1st line) =>…
-
0
votes1
answer110
viewsHow to create a CSV file with the pixel values of an image
I’m having trouble getting the data from the pixels of an image and write to a CSV file, follow the current code. The error is in the .writerow, however I cannot identify how to change to work.…
-
0
votes1
answer51
viewsDifficulty passing column in filter_by as parameter in Python3 function with Sqlalchemt
I’m using Sqlalchemy to work with database tables. I am creating classes for the proper tables, where I have as methods of these classes, Insert, filter_all(), etc. I’m using the following class…
-
0
votes1
answer292
viewsEdge -1 using erode and dilate (Python)
I’m having difficulty creating an edge with -1 pixels around what was labeled in the image. Where 255 is what has been labeled and around this area of 255 I want to put -1 which will be an edge to…
-
0
votes7
answers1969
viewsHow to remove repeated numbers from a python list
Hello guys I’m doing a course in python and currently I Completed this exercise. Write the remove_repeated function that takes as a parameter a list of integer numbers, checks whether such a list…
-
0
votes1
answer124
viewsHow to get a person’s friends and followers on Twitter using the tweepy library?
The function getting_friends_follwers() below works if I remove the value 100 from (cursor2.items(100)) . My goal is to take these names (followers and friends) and save in a file "friends.txt". The…
-
0
votes1
answer27
viewsPrintable images with the Pillow library
I am developing an automatic certificate issuance project where I use the pandas to pull the names of a spreadsheet and Pillow to write the names in the certificate. The problem occurs when printing…
-
0
votes1
answer2767
viewsValueerror: Input contains Nan, Infinity or a value Too large for dtype('float64') ( I did the check and none of these proceed)
I’m working on a python linear regression project, but there’s been a problem with the.fit() model. the following errors occur: in the code I put here: Valueerror: Input contains Nan, Infinity or a…
-
0
votes1
answer64
viewsReduce running time in Python simulation
Hi. I’m trying to solve a problem where I have to create a function that receives a string of 0 and 1 and a list of commands, which can be 'I' and 'Q'. If it is 'I' the program must modify all…
-
0
votes2
answers351
viewsPython Playsound is not playing an audio
I created a program that synthesizes a Python speech with the gTTS library, but at the end when I play the saved audio this error appears: Traceback (most recent call last): File…
pythonasked 4 years, 7 months ago Nícolas Carvalho 21 -
0
votes1
answer1090
viewsFind element using Python + Selenium
Hello, I am trying to click on an element using webdriver with pythone Selenium The element : <a class="ppm_button_menu_item" alt="Exportar para CSV" href="javascript:clarity.uitk.exportToFile(…
-
0
votes2
answers110
viewsHow to separate a string by passing more than one parameter
I have the following text file, except as texto.txt: Vamos testar nesse arquivo, aqui. Temos que pedir para, que separe "todos os caracteres"! Fazer, a contagem de letras? Fazer a contagem de cada…
-
0
votes2
answers345
viewsWeb scraping with Beautifulsoup - find_next does not return text
I want to extract the text from the section below: <div class="matchDate renderMatchDateContainer" data-kickoff="1583784000000">Mon 9 Mar 2020</div> the text would be "Mon 9 Mar 2020".…
-
0
votes1
answer94
viewsProgram for process automation
I’m writing a program in Python to automate one of my work routines. But I came across a part where I can’t go on, look: At this stage, I need to write a code that identifies the lowest value of…
-
0
votes1
answer119
viewsPopulating a dictionary of dictionaries through a for loop
I’m trying to create a loop to add information in a dictionary. The most external key of the dictionary will be the name of a course, and the value will be another dictionary, there will be 6 keys,…
-
0
votes1
answer378
views(Tkinter) How to leave Labels, Buttons, and Frames with the tranparente background?
I’m trying to make a program in Python with Tkinter to make records and so on, but when trying to put a photo in the background image it is impossible to remove the white spaces that Tkinter does…
-
0
votes1
answer24
viewsplotting plineplot with Seaborn excluding certain elements
I would like to plot a lineplot with sns but didn’t want it to plot a specific line sns.set_palette('Accent') sns.set_style('darkgrid') ax = sns.lineplot(x=dados['date'],y=dados['cases'],err_style=…
-
0
votes1
answer24
viewsHow to split the instance of a class through outrw
To be more precise, yesterday I opened a question asking for help in creating a class that acted as a creator of dictionaries, and promptly I was answered, follows the class: ` class tuplas: def…
-
0
votes2
answers398
viewsPlay again, not "clean" board - Old Python game
I have a problem with this code, it is an old game for college, it is working normal, but in the part I put to play again, when user type yes, it does not Zera the board, and gets the markings of…
pythonasked 4 years, 7 months ago Isabelle Torres 31 -
0
votes2
answers88
viewsProblem with Python print formatting
This code is to solve a problem of URI,o 1179, it gives error Presentation, because there is a space in the answers, between brackets, the problem is in the prints inside the loops for. Can you…
-
0
votes2
answers768
viewsHow to fill a column of a pandas dataframe using corresponding values from another column in another dataframe?
Hello. I am working on a personal project and need a help. I have 2 dataframes: solicitacoes = pd.DataFrame({'ID':[1,2,4,5], 'Equipe':['A','B','C','D','E'], 'Emissor_da_ordem':['Joao Pedro','Maria…
-
0
votes2
answers281
viewsQuestion about recovering data from database
Good morning. I am a beginner in programming and had an opportunity in a project at work to become a developer. The project is only a panel showing some database data from our main application. I am…
-
0
votes2
answers120
viewsHow to extract data from a single column list and generate another?
Good morning. I’m new to programming and I started out with curiosity and the need to eliminate some repetitive functions from my day to day. I am creating a code that enters a network equipment…
-
0
votes1
answer135
viewsError when connecting an IP camera to Opencv (-215:Assertion failed)
Good afternoon, guys! What’s up? So, I’m trying to connect a webcam per ip to the open cv, the webcam would be the camera on my phone and I’m using the Droid cam for that. It happens that I always…
-
0
votes1
answer559
viewsConvert BGR to RGB (Opencv)
I have a code that finds the edges around what was labeled in the image and places the value of -1 in the pixels of that border found. I’m having trouble converting the image already with the edges…
-
0
votes1
answer74
viewsFormat an object print
Time, I need to format the print of the following class: class Tupla: def __init__(self, keys, palavras): self.keys = list(keys) self.palavras = list(palavras) self.op = dict(zip(self.keys,…
-
0
votes1
answer100
viewsPosition reopening screen Python Tkinter
I am developing a program in Python and use Tkinter to create a screen as below: import tkinter as tk def on_closing(): cpos = str(root.winfo_rootx()) + '+' + str(root.winfo_rooty()) # salvo o cpos…
-
0
votes1
answer33
viewsHow to create a class attribute with predefined Python types?
I consulted at documentation from Python, but I couldn’t find a syntax for how I could create an attribute from a class that has a predefined type. I took as an example this exercise of W3schools:…
-
0
votes1
answer299
viewsHow to access a private attribute in Python, I created an object from another class that has private attributes as well
I created an object from the class Especificacoes, and by creating a class obejto Geradores, I passed the object created from Especificacoes as a parameter for class Geradores. Note that the…
pythonasked 4 years, 7 months ago Lauro Mendes do Amaral Junior 21 -
0
votes1
answer413
viewsHow to read text boxes, and create action from the button in Pyqt with a form created in Designer?
Good, I designed a widget in Qt Desginer, and converted to python, and using the tutorial, I can run the widget (two textbox, 1 button and a label). The idea is to add the contents of the boxes,…
-
0
votes1
answer368
viewsObtain the quantity of odd numbers, positions of the pairs and average of the positives, from a tuple of numbers
I have to declare a tuple with 10 integers and I need to find the amount of odd numbers (already done), the positions of even numbers (need help for this logic) and the average of positive numbers…
pythonasked 4 years, 7 months ago user182069 1 -
0
votes1
answer310
viewsTkinter - Manipulation of buttons using PYTHON GRID
Good evening, I’m having difficulty with the module Tkinter in python, I’m creating an email generator and I need to position some buttons on the screen but the use of columns do not allow me to…
-
0
votes1
answer99
viewsI’m creating flap by the pygame and the animation is not working well
So following as I said in the title I am creates a flap Bird , I have not yet implemented physics and the tubes however my problem is being with his animation , What’s happening is that it only…
-
0
votes1
answer79
viewsSlice and store Ict in pyhon
I have the following class: class Buckts: def __init__(self, keys, palavras, tamanhoP): self.listaBuckts = dict() self.keys = list(keys) aux = list(zip(keys, palavras)) self.aux2 = list() for i in…
-
0
votes2
answers265
viewsSplit sublist in python
Good team, I have a method that receives a list and from it creates sub-list and attaches in Buckets: def indexar(self, keys): buckets = [[] for _ in range(10)] for i in keys: for ii in range(10):…
-
0
votes3
answers60
viewsShorten Object Method Call
Recently I was doing college exercises, we’re seeing inheritance, and I made a code that generated many lines to demonstrate that class inheritance is working, there’s some way to shorten those…
-
0
votes1
answer343
viewsSplit dictionary in python
Good guys, even for help here from the forum, I got a function that creates sub-list from sub-lists according to the division by 10, is easier to understand with the code: def indexar(values): #…
-
0
votes2
answers43
viewsError in display of dictionary information
I am early in python and I am having a difficulty in the following code: class Gerador: def __init__(self, nome, potencia, capacidade_energia, capacidade_combustivel): self.__nome = nome…