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
votes1
answer4440
viewsConcatenate pandas dataframes with different column names
I have two pandas Dataframes that I would like to match into one. They have the same number of columns in the same order, but have headers with different names. Is there any approach to efficiently…
-
0
votes0
answers35
viewsPython - CTR class does not register in DB
Good night. Application developed in Python 3.x Database: sqlalchemy. I’m trying to develop a simple product registration system in an SQL database. For this, I am trying to develop from the MVC…
-
0
votes1
answer104
viewsHow to transform a list that will be given at the input into a matrix?
I’m trying to turn this list that was given to me at the entrance into a matrix u l i o a e a p b e a r y l s j i t u a e e h u b e u o r r c t n e p b i o s b This is one of the input examples, my…
-
0
votes2
answers336
viewsTypeerror: not all Arguments converted During string formatting (python)
I’m new to programming, I’m trying to make a program that checks if a number inserted is prime, so I’m checking if the rest of the division of number by primes is zero. def primo(): numero =…
pythonasked 6 years, 9 months ago Gabriel Andrade Vianna 31 -
0
votes0
answers407
viewsComparing two python data frames
Good afternoon gentlemen. I am new to python, and to programming. I am trying to compare two different data frames, each with the data of cars of a specific year. For now I’ve done the following:…
-
0
votes2
answers870
viewsAdding total sum grouped to a new column Dataframe pyspark
I have a dataframe with the following columns: COL1 COL2 COL3 NEW_COL* A asd 1 8 B adf 2 9 A adg 8 1 B adh 9 2 C adj 7 7 D adk 1 1 Where NEW_COL = (total sum of col1 by type - the value of col3) /…
-
0
votes0
answers91
viewsCache Storage with Python
I’m trying to use WPA in a Flask app. I wonder if it is possible with Flask or Python to store my pages in the browser’s Cache Storage? From what I’ve seen so far I’ll have to use javascript, but…
-
0
votes2
answers45
viewsTwo doubts about Kinter
I have two questions about GUI Tkinter. The first is: how do I stop when the text of a label is larger than the label size, the text instead of being missing, continue on the next line. The second…
-
0
votes1
answer131
viewsHow to create tuple with key receiving value?
I would like to create a method that returns the Django ORM FILTER parameters. I will have to use these filters at various times, I would like to create this generic method. Follow the example: def…
-
0
votes0
answers40
viewsHow do I update a button when attending an external event?
I made a small application where it communicates with an external drive consulting some boolean variables. Depending on the status of these variables, a button is placed on the screen and a picture…
-
0
votes1
answer38
viewsHow to play a background audio?
I’m making a python program that runs inside an infinite loop.. Under certain conditions I need to play an audio, but I cannot wait for the audio to finish to continue the process. I thought of…
-
0
votes2
answers297
viewsHow to find the most common value within each column of an array using python?
I have a matrix (3 x 3280), I need to go through each column and consequently each row and find the most frequent value and thus generate another vector (1 x 3280) with these values. For example:…
-
0
votes1
answer854
viewsPYTHON - how to use a loop without stopping Tkinter
I have this program which is a kind of 'Force Brute' (I automated a process of clicking on a place, typing a number, and clicking elsewhere with @Pyautogui), I need to use a loop but when the loop…
-
0
votes2
answers1192
viewsPython matrices - Concatenate
Hello, I have two matrices and I would like to concatenate them, that is, put in a third matrix the matrices A and B one next to the other, in case form a matrix 3x6, but using a loop (command…
-
0
votes1
answer84
viewsPython - How to make a Packet logger from a server?
Python - How to make a Packet logger from a server? Hi, I was wondering how do I create a python Packet logger that would have the following functionality: Receive information from the game server,…
pythonasked 6 years, 5 months ago Richard Santos 74 -
0
votes4
answers3471
viewsMatrix generator in Python
The program does the following: I say the number of rows and columns I want in my matrix and then assign a value to each column in each row, the problem is that when I specify the number of rows…
-
0
votes1
answer2113
viewsUse a function variable in another python function
I want to pull what is in the variable 'file' in the function 'Function' and play in the filename of the function 'send_email', how can I do this? def function(event): arquivo = open('log.txt', 'a')…
-
0
votes1
answer160
viewsAccess variable via exec
I was trying to create a "shell" to be able to communicate with a python program during its execution, so far I have the following (this code is just an example): import sys, pygame from threading…
-
0
votes0
answers110
viewsHelp with python requests
I want to create a python BOT to send login POST requests, and then send another request to create character, but when I run the code it does not create any character, someone can help me ? import…
pythonasked 6 years, 9 months ago Courin da mata 1 -
0
votes1
answer440
viewsHow to fix ipykernel_launcher.py: error: unrecognized Arguments in jupyter?
I’m following this one tutorial tensorflow after two days preparing the environment in Anaconda I finally managed to perform premade_estimator.py using the cmd but when I try to run the same code in…
-
0
votes1
answer697
viewsHow to find the highest value of a matrix?
Well, I have a 3x4 matrix and I want to know how to develop a python code to get the highest value of this matrix. My code made so far was this: LINHAS = 3 COLUNAS = 4 LINHA_ MatrizM = [] for i in…
-
0
votes2
answers249
viewsPython script does not generate chart as expected
My Python algorithm is running perfectly, I just can’t generate the graph! I couldn’t identify the error... What’s wrong? import matplotlib.pyplot as plt va=float(input('Digite o valor a ser…
-
0
votes2
answers69
viewsProgram with boolean expressions enters the if block every time
prefixes = "JKLMNOPQ" suffix = "ack" for letter in prefixes: if letter[0] == "Q"or"O": print(letter+"uack") continue print(letter+suffix) Expected response: Jack Kack Lack Mack Nack Ouack Pack Quack…
-
0
votes1
answer6606
viewsHow to compare a list of numerical values with another Python variable
I need to do a function that compares the values of a list with a variable, returns the value of the list nearest or equal to the value of the variable. ex:The list is list = [1,2,3,7] and variable…
pythonasked 6 years, 9 months ago Carlos Storari 163 -
0
votes1
answer125
viewsPython/ Selenium is not filling the tilde (~)
I’m trying to use Python / Selenium / Webdriver to automatically fill in an entry field on my Chrome page. However, I am unable to use the "send_keys" command to fill the til character (~). Here is…
-
0
votes1
answer798
viewskivy in python 3.6
I am using Python 3.6.2 and am learning the kivy. The script does not rotate because it lacks the sdl2. I already installed the pillow and the pillow-PIL, but I can’t install the sdl2. I tried the…
-
0
votes0
answers70
viewsOpen DB Berkeley Python
I received a project where I have a file . db I tried to open it with Sqlitestudio and Sqlitemanager, I was unsuccessful. I was informed that this db was a database Berkeley. I would like to open…
-
0
votes1
answer635
viewsDjango 2.0 - Amigavel Urls
I’m studying Django 2.0.2, and I’m having difficulties in URL friendly together with Slugfield in the models.py class, but I don’t know how to define def get_absolute_url(self): correctly. I can…
-
0
votes1
answer80
viewsProblems with dictionaries and lists - python
Hello, I have the following dictionary. datas = {'records': [{'createdTime': '2018-02-20T21:56:20.288Z', 'fields': {'publicacao': '2018-01-22'}, 'id': 'rec1c1c8qyIkdwyMD'}, {'createdTime':…
-
0
votes1
answer295
viewsHow to customize matplotlib Plots, in a more Clusterization-oriented way?
I am working with data analysis, I need to leave the data more distant from the clusters represented in some other way, as a different symbol or some stronger color, I analyzed in the documentation…
-
0
votes1
answer3305
viewsIn pandas, how to merge two dataframes, but only one section of two columns?
In Python 3 and pandas I have two dataframes eleitos_d_doadores_d.info() <class 'pandas.core.frame.DataFrame'> Int64Index: 16090 entries, 16 to 26412 Data columns (total 23 columns): uf_x…
-
0
votes1
answer737
viewsHow to check existing data in comics?
I need to check if a data already exists in the BD before registering it in python, where the bd has the Videocapture table and its attributes are id, name, value.... need to verify the name before…
pythonasked 6 years, 5 months ago Adryan Alencar 51 -
0
votes1
answer906
viewsLimit when creating a list in Python
With the following command, I can create a Python list: lista = [[None]]*50 I will have a list of 50 units. However, if I create a list this way: lista = [[None]]*50 for l in lista:…
pythonasked 6 years, 5 months ago Vinicius Morais 1,293 -
0
votes2
answers231
viewsHighlight main words of a text in order of a ready list
I have a very basic basis that I would like to highlight the main words of each line of a prioritization list, example: Groundwork: Bom dia que dia lindo vamos embora vamos chutar o dia…
-
0
votes1
answer178
viewsHow to ignore Django.contrib.auth Migrations?
I have a Django application where I intend to customise the authentication part. I’ve already made my own Backend of authentication, as well as configuring my own Model that will be used in…
-
0
votes1
answer149
viewsSelect the two highest values of a vector and add them up?
atletas = [] while True: nome = input("Nome: ") if not nome: break saltos = [] for i in range(3): salto = float(input("Distância {}:…
-
0
votes1
answer1779
viewsHow to grab and save many data entries in python?
Guys I’m starting to program and so far the data inputs were like this: dado_1 = str(input('Seu nome: ')) dado_2 = int(input('Sua idade: ')) dado_3 = str(input('Sexo: ')) But I was left with a…
-
0
votes1
answer692
viewsUse of the comma in Python
I’m having a problem understanding the difference between code 1 and code 2 (Fibonacci sequence). Apparently it looked the same, but the results they both print are distinct. Code 1 qtd_elementos =…
-
0
votes1
answer939
viewsDiscover hosts from the network
When trying to create a script on the subject I got some questions about the script below! The question is, how am I going to do the "for i in 100" so that it will ping the ips, like…
-
0
votes1
answer699
viewsTkinter, how to update label on canvas?
Hello, I am trying to build a dynamic table that updates the values automatically but I am not able to update the Labels, I am using the following code: import tkinter as tk def populate(frame):…
-
0
votes2
answers912
viewsPython: find product of the highest value of each matrix list
Dear Ladies and Gentlemen(s), I’ve done a lot of research before posting my question. I am already discouraged. This is a university job. If you can give me a hint, I’d appreciate it. The exercise…
-
0
votes2
answers55
viewsFind the index in a value-based array of dictionaries
If I have an array of dictionaries and want to find the index in the array of a certain dictionary value, as I do? Ex: palavra1 = {'palavra': 'valor1'} palavra2 = {'palavra': 'valor2'} palavras =…
pythonasked 6 years, 5 months ago Gabriel Augusto 530 -
0
votes1
answer84
viewsWhy is the text label not changed?
I have a screen class, which contains a label of text, the code loads an xml containing the objects. py screen.: #!/usr/bin/python3 import gi import modulo_arquivos import os…
-
0
votes1
answer565
viewsPython and pymysql connection
I’m creating a login system and user records. I created a model to do the insertion and controller, validating the information and step for the model to save, however, my model is not working. Here…
-
0
votes1
answer72
viewsswitching from one entry to the other when typing a word
Guys, help me with this, I have two entry and I need that when I type a word for example (Python) it changes from one entry to the other automatically from tkinter import *…
-
0
votes3
answers783
viewsHow to input() stop after space instead of line break in Python3
I’m looking to capture several numbers on this graduate: 2 4 5 3 5 0 4 As a number of numbers undefined and without using an auxiliary list, I want to use only one variable for _ in range(0,n): num…
-
0
votes1
answer684
viewsRandint does not generate random numbers the second time I use it
My randint when used the second time it does not generate new random numbers, it remains with the same generated numbers. I know that in C when this happens I can use the srand(time(NULL)); , but in…
-
0
votes2
answers206
viewsImage displayed on one machine, and another not on Django
I have an app in Django that runs in two places, one at work, which is where there is effective production, and in my house, which is where I make the adjustments because here I have time. The…
-
0
votes1
answer120
viewsFind a certain word in a particular Tweepy user
Following the documentation, I was able to create a code that extracts tweets by tag, and another that extracts tweets from some user. But I’m having trouble extracting tweets from someone by tag.…
-
0
votes1
answer61
viewsTkinter, how to use the same script in win and llinux without the window icon getting in the way
I’ve been writing some scripts in Win VS and when I switched to Linux, I came across the following problem: When I use an image as a window icon in Linux (which does not have it), the script does…