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
votes6
answers342
viewsGet a list of the first multiples of a number
I need to do a program that determines the first 5 multiples of 3, and I wanted to put the values of the first 5 numbers into a variable, but I don’t know how to do that. I tried to make: for index…
-
0
votes1
answer81
viewsGenerate a python array of multiple variables
Hello! I am trying to generate a function that reads imported data from a "csv" file and converts it to an array. The data of one column is integer, and of the other column is an intercalation of…
-
0
votes1
answer44
viewsProblem with socket - recv - python
Hi! Here’s the thing, I got a customer problem. When I use netcat as a server, the client sends the message "connection received successfully" and then returns the following error: Exception…
-
0
votes0
answers103
viewsPython connection with SQL Anywhere 16 fails
Hello! I’m trying to connect Python with a Sybase database but all the ways I try, ends up giving this error. Traceback (Most recent call last): File "C: Users Yuri.Mendonca Appdata Local Programs…
-
0
votes2
answers1550
viewsDraw Inside a Python String
I am doing a program in Python, whose statement is as follows:: Create a function that takes a string and turns some of the characters into uppercase and others into lowercase. I need the user to…
-
0
votes0
answers11
viewsCreate graph with plt.pcolormesh
I am trying to create a graph to visualize current speeds. I have put the following code: plt.figure(figsize=(14,2)) plt.pcolormesh(tempo1,niveis,np.transpose(v1u)) plt.title('v1')…
-
0
votes0
answers35
viewsParameter "-noconsole" is not working
I have a Python project that uses Pyqt5 and when I run the executable through pyinstaller with the command: pyinstaller --noconsole --onefile --windowed main.py is generated the executable where I…
-
0
votes1
answer98
viewsHow do I delete part of a string in a pandas.Dataframe
I have a Dataframe with the column Assinatura.Cadastro, but the date and time is all together. How can I leave only the hours field, excluding the date ?…
-
0
votes1
answer26
viewsHow to compare the elements of a list
So, I need to develop the body of a code that travels through a list already ordered to find out in which positions are the equal elements. How do I do that?
pythonasked 3 years, 9 months ago Maria Fernanda 3 -
0
votes1
answer31
viewsProblem with scope of variables in child class
I created an interface with Tkinter to use as Environment for my studies with reinforcement learning. My goal is to run the class that creates Nvironment and with an external loop, send actions to…
-
0
votes2
answers82
viewsHow to store different values in a single variable
I wanted to take a variable and store different values. In this case, it would be 7 ages, how to do? cont = 0 anos = 0 for c in range(1, 8): cont += 1 anos = int(input('Em que ano a {} pessoa…
-
0
votes2
answers800
viewsHow to perform two functions, both containing infinite loop, simultaneously in Python?
I have in the file Connections.py two functions, one where I am reading the 'status' field of a table every 1 second. I also have another function in this same file doing the same process, but in…
pythonasked 5 years, 2 months ago João Paulo Silva 15 -
0
votes2
answers2134
viewsMake input accept only positive numbers
I’m doing a factor calculator program, which is already running right. But I don’t know how to do the input of this program accept only positive numbers. I tried with isdigit: n = int(input('Digite…
pythonasked 5 years, 2 months ago Natanael Ricardo 47 -
0
votes1
answer144
viewsHow to draw a draw for an element of an array within a specific range?
I have a Python code, where I have an array (g) of 10,000 elements. After performing a draw using Andom.Choice(g) that draws any of these 10000 elements. However, I would like my final value to be…
-
0
votes1
answer85
viewsHow does Modern Opengl work?
I already studied Opengl, and now I was reading Modern Opengl, I was watching some videos on Youtube and some tutorials on the internet and I wrote this code: import pyglet, numpy, ctypes from…
-
0
votes1
answer289
viewsHow to multiply all elements of an array by number in Python?
I need to do a function that given a matrix and a number, returns the resulting matrix by multiplying all elements of the matrix by that number. I tried something like this: def mult(matriz, n):…
-
0
votes2
answers1301
viewsLINUX run python script on terminal
I created a simple script in python then a launcher on the desktop to run this script on the terminal but it is not opening the terminal. When I click to open the launcher nothing happens. hello.py…
-
0
votes1
answer34
viewsFunction does not work in all test cases
I need to do a function to check if a matrix is square: def eh_quadrada(matriz): '''Função que verifica se uma matriz é quadrada. list->bool''' if len(matriz)==len(matriz[0]): return True else:…
-
0
votes1
answer53
viewsScript created in Pycharm closes by pressing the "enter" key inside the terminal
Here’s the thing. I’m new in the middle of programming. I use Pycharm to study python. When I try to run a script created in Pycharm by IDLE, just after I hit the "enter" key the window closes.…
-
0
votes1
answer335
viewsExit an Iframe Selenium Pyhton
I’m having a hard time... I have a page to manipulate with Selenium, my problem is Iframes. I access a main Iframe and within that main iframe I have other iframes to manipulate, my porblema is that…
-
0
votes1
answer386
viewsOpen text file in float value list
I need to open some files I have here that are in txt format which is even less common and specific in data processing issues, these files consist of values from 0,000 up to 0,999 and also from…
-
0
votes2
answers873
viewsHow to know if a number is an integer or a float? And how to assign a type to a value inserted in the input function
I have the following problem: Make a program that takes any two numbers (integers or real) and print on the screen the integers that are in the range understood by them. And I made the following…
pythonasked 5 years, 2 months ago Ana Carolina Esteves 71 -
0
votes1
answer67
viewsTkinter.filedialog does not work with Toastnotifier
I am creating a virtual assistant that communicates with the user through notification messages. I researched a lot on the internet about and found the win10toast. So far the program is working…
-
0
votes0
answers150
viewsMaking operations inside the Dataframe
I’m trying to do the following thing with this code import pandas as pd from datetime import date # Criando uma série no pandas que represente a indexação das linhas como valores temporais # Por…
-
0
votes0
answers149
viewsHow do I get the angle of an image gradient, using Python and Opencv
I need to get the angle of the gradient of an image, I’m programming in Python and using Google Colab for the codes. I found this code here, which should show me the angle of the gradient: import…
-
0
votes0
answers13
viewshow to install an internal package of requeriment.txt in python?
For example, I have a python code that uses the library import geocoder. In my machine I’ve used the pip install geocoder, but when a colleague made a git-clone it didn’t run for lack of this…
-
0
votes2
answers115
viewsLimit decimal places
I’m making a simple program that generates two random numbers and asks the user how much is that number +,-,/,* for another number, and I want them to have decimal numbers as well, but when I use…
-
0
votes2
answers479
viewsHow to filter items in the Foreign key field of the Django form?
Good evening! I’m new to python/djagno, and I’m new to the community, too, that’s my first question. What I want to do is filter the items from a selection list of a Foreign key (Template) on the…
-
0
votes2
answers306
viewsPrint only palindromic words
Training python, I was able to make a program that checks if the input is a palyndrome word. Follow: def palindromo(texto): if len(texto) <= 1: return True else: return texto[0] ==…
-
0
votes3
answers2047
viewsaverage of values typed in python input
I’m doing a program that picks up a value typed in input (which is not negative and is less than 20) and calculates: a) The highest value; b) The lowest value; c) The sum of the values; d) The…
pythonasked 5 years, 1 month ago Natanael Ricardo 47 -
0
votes1
answer33
viewsSeparate a Dataframe
I would like to know a practical way of separating a Dataframe into several by the column value state. For example: AC = covid[covid['state'] == 'AC'], AL = covid[covid['state'] == 'AL'], AM =…
-
0
votes1
answer52
viewsLoad multiple Amazon S3 files
I’m trying to load multiple files that are on Amazon S3, I’m using Panda, Anaconda, but I’m in error. bg = s3.Bucket("bucket") objects = bg.objects.filter(Prefix="bucket/") for obj in…
-
0
votes1
answer69
viewsPython Type Error a float is required
When I print C1.getTotalDesconts() and C1.getSalarioLike() for some reason python is requiring a conversion to float, these methods always return int or float, I can’t imagine the reason for this…
-
0
votes2
answers115
viewsMake a sequence of letter combinations start with a specific letter
from string import ascii_uppercase import itertools import time for seq in itertools.product(ascii_uppercase,repeat=3): sseq = ''.join(seq) for z in range(11111, 100000): passcode = ('%s%05d' %…
-
0
votes1
answer85
viewsOpen Python file in a different folder (Explorer)
I would like to know some way to open a file (example, a .csv to do some data analysis) from Windows Explorer. Example: arquivo = open('arquivo_1.csv','r') but with the file 'arquivo_1.csv' coming…
-
0
votes4
answers197
viewsPython, how to calculate the average of a list of 5 in 5 elements?
I have a problem where I need to calculate the average of 5 out of 5 elements in a list, for example, average the first 5 elements, then average the next 5 elements and so on. I tried using list…
-
0
votes0
answers37
viewsWho connects to the Sqlalchemy database?
I have an app that uses Sqlalchemy’s ORM, but I’m confused about this connection. It is Sqlalchemy or the connection driver (in my case psycopg2) that actually connects to the database?…
-
0
votes1
answer33
viewsMake a query with pymongo filtering by a string ignoring uppercase and minuscule letters
I need to make a query in a database in Mongodb using the pymongo library in python, the query I am making is as follows: dbCliente.find({"nome": "carlos"}) I want to return the client whose name is…
-
0
votes1
answer28
viewsFutsal (error) - Python
Good people, I’m making a futsal code and I’m having certain obstacles with it. Currently, I am studying Python and for the first time applying POO, so I need you to give me a light on how to…
-
0
votes1
answer30
viewsUp to how many different levels can a classifier predict?
I was recently doing a machine learning model and I was wondering if I should use logistic regression. The documentation says that this classifier can predict binary values (0 or 1). In my case, I…
-
0
votes1
answer28
viewsError to excrever data frame in Excel
I’m trying to extract some data and write to an excel file. However, they come with a Shape=(1,209,26) which generates the following error when trying to pass to the . xlsx "Valueerror: Must pass…
pythonasked 3 years, 9 months ago Diego Silva 13 -
0
votes0
answers52
viewsTelegram bot sends message correctly, but then sends an error: "Something Went Wrong, Please Try Again."
Please help me, suddenly my Telegram bot on Heroku is sending the correct message and below an error! Output Result on Telegram channel: aaaaaa Something went wrong, please try again. The tickle:…
-
0
votes1
answer22
viewsHow to embedding sentences for NLP in Tensorflow?
I need to turn a phrase bank that I created myself into a suitable vector to use as training a neural network in Tensorflow. I have the following structure: I managed to separate the sentences into…
-
0
votes1
answer134
viewsLoop to perform quantity processes in quantity
I have a size 30 list in python, I need to make a loop to catch 6 item from that run list, after we finish the 6 run over 6 and so on until finalizing the list. but I’m not finding a way to do that.…
-
0
votes2
answers282
viewsPython - Remove elements from a list
I have a list in Python and I want to replace certain elements in it, already try to use the replace mode I found in the documentation, but I did not succeed because it cannot be used in lists. I…
-
0
votes1
answer507
viewsWeb scraping with python on authenticated websites
I am trying to automate a web data collection process using Python. In my case, I need to pull the information from the page https://app.ixml.com.br/documentos/nfe. However, before going to this…
-
0
votes2
answers38
viewsComparison of content in matrices
Have some python solution to use something similar to np.all in arrays that are filled with strings or ints? Below an example of what I wish, perform the comparison of a row of the matrix to verify…
-
0
votes1
answer1805
viewsRemove Automatically Generated Number Column in Dataframe Pandas
I created a dataframe in pandas, everything works perfect, but when I export to Excel, it appears this first column with these numbers. I would like to remove it, but commands like . drop do not…
-
0
votes0
answers321
viewsVBA running python - Script does nothing
Good afternoon, I have a VBA command calling a specific Python script. What happens is that if I run the script manually, it works perfectly, no problem at all. Running by VBA it only gives the…
-
0
votes1
answer432
viewsQueue - Python (order)
Let’s simulate a queue situation at the bus terminal. Write a function that receives a NAME LIST (strings) that indicates the order of arrival of people to catch a bus from the terminal. Your role…