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
votes2
answers666
viewsGet the user logged in to Django Admin
Good morning, you guys. I have a small application made entirely in Django Admin and I need to get the user logged in to make a specific query listing registered customers and and other models by…
-
1
votes2
answers87
viewsHow to remove all elements from a list equal to a certain value
How to remove all values from a list that will have the same meaning for example: array = ['sim', 'sim', 'sim', 'sim', 'sim2', 'sim3', 'sim4'] Is there any way to make a looping loop as long as…
-
1
votes0
answers26
viewsSwitch windows in wxpython without destroying the previous one
Good afternoon, I’m new to Wxpython and I’m only trying to have the "frame1" registration update the window to the Mainframe that will mount a Pie Chart. I don’t want the window to be destroyed,…
-
1
votes0
answers38
viewsTrying to program puzzle changing elements into equivalent positions of two error arrays
I’m trying to make a puzzle in which the image comes scrambled into pieces, and by clicking on two different pieces they change position, if the drawing is correct it goes to the next. But the…
-
1
votes1
answer49
viewsI can’t get xpath from comment box on Youtube
I need to be able to comment on Youtube, but XPATH does not work, even with the right parameters, I tried with ID and ELEMENT but I was not successful. from selenium import webdriver import keyboard…
-
1
votes2
answers53
viewsBrowse and collect data from dictionaries within a list
I have a list of several dictionaries containing registration data: [{'sex': ’M', 'age': 44}, {'sex': 'F', 'age': 33}, {'sex': ’M', 'age': 55}] I created separate functions to calculate the average,…
-
1
votes1
answer450
viewsSave Captured Data and Executed Commands with Python
I need to use Python to make several commands on a system, and at the same time go saving in a dataframe everything that is being done. There will be hundreds of commands per minute, for several…
-
1
votes3
answers155
viewsHow do I remove the last "," that appears in the print?
How do I remove the last , that appears in the print? x = int(input()) z = range(x) for i in z: n = 2**i print(n, end=", ") When I run the show he returns it to me: 1, 2, 4, 8, 16,…
-
1
votes0
answers17
viewsHow do I check if a key has been pressed in Python
Hello I am developing an algorithm to make a scrolling of Dungeons & Dragons plug, and as much changes in the plug I wanted to make a scheme where by pressing some key I could modify some value,…
-
1
votes1
answer76
viewsHow to load whole values from a txt file? - Python
I want to load a dictionary where the text file .txt contains information of the type String, but I want the values to be loaded Inteiro. {'11322567498': '[0],[0]'} Note that values are always being…
-
1
votes1
answer2252
viewsPython Login and Registration System
I am trying to develop a simple registration and login system using text files, but at the time of login is giving error. I believe it is in the variable "Registered", because from what I understood…
-
1
votes1
answer1336
viewsLoad Chrome profile in Selenium
I’m trying to upload my Chrome profile but can’t, which is missing? from selenium import webdriver from selenium.webdriver.chrome.options import Options class Teste: def __init__(self): self.driver…
-
1
votes4
answers406
viewsReturn the missing element from a list of integer numbers
Make a function called missing that, given a list with N 1 integers numbered from 1 to N, finds out which integer of this range is missing. I can’t find a code that covers any list of integers. def…
pythonasked 4 years, 1 month ago Marco Raad 43 -
1
votes1
answer4825
viewsManipulation of Excel in python
I would like to update excel every time the program runs, but the library only lets me write a new excel, and not update it. How can I do that? import requests from bs4 import BeautifulSoup import…
-
1
votes1
answer68
viewscompare string
I have an input with the name "city" which is a string and I need to make sure that if the user enters a number or does not type anything he receives an error message, as I could do? Follows the…
-
1
votes1
answer30
viewsHow to write in a file the number typed by the user and the value given by the program?
How can I write only the value typed by the user (the value of n typed by it) and the result given by the program (reply) into a single file? def fibonacci(n): r = [-1]*(n + 1) return fibonacci_2(n,…
pythonasked 4 years, 1 month ago Ricardo Nascimento 23 -
1
votes1
answer485
viewsDjango 2.2 error - mysql connection
Hello! Here’s the thing, I’m having a problem connecting to mysql with Django. The error is this: Django.core.exceptions.Improperlyconfigured: Error loading Mysqldb module. Did you install…
-
1
votes2
answers246
viewsHow to read Mysql data with Python?
I’m running a registration and product sales system. I need to have access to registered units to check how many units still remain to be sold (with each sale I’m decreasing the remaining units). I…
-
1
votes1
answer62
viewsPython: because when declaring the constructor of the Daughter I also have to declare the constructor of the Mother?
I am developing a small application in Python and I came across a question that I could not draw a concrete conclusion about why this should happen. Simply put, the problem is this:: The following…
-
1
votes2
answers168
viewsWould you like to make a code that spells out the word?
I’m new to programming and I’m trying to put together a script where I type in a word and he spells it out for me! I’ve assembled the following code! nome = input('palavra para soletrar:') while…
-
1
votes1
answer121
viewsHow to resolve "An Attributevalue may not contain an Empty string"?
Hello, I am doing some simple tests for integration of the API Gateway with Dynamodb, at this moment I can do a GET and POST using POSTMAN and GET in python, but I cannot do the POST in Python, I…
-
1
votes2
answers55
viewsHow to catch the smallest hints from the list, but only from Dice 0 to 1
z = [-4, -1, 0, 0, 0] F1 = [ 9, 1, 1, 0, 18] F2 = [ 3, 1, 0, 1, 12] #Pega a posição do menor valor das listas n_min_z = min(z) n_min_F1 = min(F1) n_min_F2 = min(F2) #Guarda a posição em uma variavel…
-
1
votes1
answer221
viewsSet steps_per_epoch is dramatically increasing training time
This is my training function: model.fit(train_states, train_plays, epochs= numEpochs, validation_data = (test_states,test_plays), shuffle=True) When I don’t define Steps per epoch, I get this: Train…
-
1
votes3
answers166
viewshow to find the indexes of an item that repeats in a list in Python
have a list l = [1,6,6,2,3,6] and I want to form another with all the indexes of the element 6. In this case, the second list should be l2 = [1,2,5], however, when I try to use the l.index(6),…
-
1
votes1
answer375
views(Python + Pyqt5) How to not let main application be closed without closing "daughters" windows open.?
I have my main application with menus (Menubar) where calls the function that creates and opens another window "daughter". My problem is in the part where I can close my main application without…
pythonasked 5 years, 4 months ago Cleber Nandi 137 -
1
votes1
answer579
viewsProblems with the vscode interpreter
Well, the Code works, I changed the vscode interpreter that was in global python 3.7 from Ubuntu even to virtualenv python, the code works, but I do not understand why this error in Problems. I’m…
python visual-studio-code importing virtualenv interpreterasked 5 years, 4 months ago Raisler Voigt 73 -
1
votes1
answer746
viewsAdd and subtract according to a criterion in another column
I have a f0519_grouped dataframe like the one in the image. " Unique Identification" is the code that identifies the employee of the others; "Code Item" identifies the payment; I also have the name…
-
1
votes1
answer513
viewsHow to create a hash using the hashlib library using the "time.time()" method in Python3
Hello, I have the following situation: I have to create a hexdigest of a concatenation of 2 numbers transformed into a string. For this, I must use the library hashlib and the project must be in…
-
1
votes1
answer1196
viewsCut part of an Image using a point list of a polygon
I have an image (see below) and a list of points that represent a given polygon of the image (e.g.. contours=[ [1430,2003], [1429,2003], [1428,2003], .... ]). I want to create a new image that has…
-
1
votes1
answer39
viewsDegree of complexity
def fRecursivo(n): if(n == 0 ): return 1 if (n%2 ==1): return (n+3*fRecursivo(n-1)) if(n%2 == 0 and n> 0): return (n+n+3*n*fRecursivo(n-1)) How complex is the code for even numbers ? In the case…
-
1
votes2
answers50
viewsDeleting lines with repeated Labels on a Dataframe
I need to delete in a dataframe lines that contain repeated labals, as highlighted in spine "B": Below is the result of how I would like it to stay after exclusion:…
-
1
votes1
answer107
viewsReplace data from one column by considering data from another in a Dataframe
I have a Dataframe with two columns B and C where the data has no relation, would like the highlighted data of the column C received the highlighted column data B, considering the same index. After…
-
1
votes1
answer35
viewsPassing dictionaries key as parameter in integrated function
I have a simple question about using working dictionaries. Is there any way I can pass the values of the ["Age"] keys of the dictionaries in the abc list as a parameter in the Mean function?…
-
1
votes1
answer37
viewsList iteration problem using any() function
I created a script to delete files from a folder and its respective subfolders. These subfolders are named as follows: 1.GERAL_%i with i ranging from 1 to 137. However, I just want to delete the…
pythonasked 5 years, 4 months ago Carlos Eduardo 85 -
1
votes1
answer82
viewsCannot read Property 'getBoundingClientRect' of Undefined
I’m trying to run a pyppeteer code (basically Puppeteer but for python instead of nodejs), and in it I run a script in the browser initialized through . evaluate(), but something in my javascript is…
-
1
votes1
answer84
viewsHow to store results of statistical calculations (mean, correlation) for later use in graphs?
[![Example of the Relevance Matrix][1]][1] I want to create a graph that is technically called "Relevance Matrix". The concept of this graph is to position the KPI (performance indicator) on x-axis,…
-
1
votes1
answer29
viewscolumn insertion via python series
I have a series collected from a column of dataframe. I need to create columns with each of this series. For example: serie = [] for s in serie: df.insert(loc=0,column=serie,value='int') columns: A…
-
1
votes3
answers95
viewsIssue in question Python String/File Manipulation
I am new to the site and I am looking for a solution to my problem. I am currently studying Python 3 and when trying to solve this issue I get an error image, I will put here my code until the…
-
1
votes2
answers1486
viewsHow to remove square brackets and commas when printing a list in Python?
How to remove brackets and commas from output when printing a list in Python? For example, I need the result of the code I did to look like this: 3 8 0 6 7 with numbers separated by space and just…
-
1
votes1
answer36
viewsQuery in Embedded Document
I’m trying to make a query to return only bank 1 investments that are not savings. How do I do? I have tried several ways and it has not worked so far. I followed the following query:…
-
1
votes0
answers278
viewsDJANGO error: Django.core.exceptions.Improperlyconfigured in the initial tutorial!
I’m a beginner in Python and I’m doing the Django tutorial and using Pycharm as IDE. When I run the command from the internal Pycharm console: from polls.models import Question it returns me the…
-
1
votes2
answers141
viewsAddition of columns in csv file - Python
I’m not able to create a csv file with a new column (month). When I try to create the whole column is only with the month of December(12) but the month column should correspond to the whole number…
-
1
votes2
answers58
viewsproblems with the Return function
I’m trying to make a program where the person has to write a number, but when she writes a number that doesn’t fit the requirements she has to write another. I can’t use the function return…
-
1
votes2
answers97
viewsSoftware with local and remote BD recording
I have a question about the possibility of doing a type of program and what means to use. Just for the record, I’m not asking for "how to do the programming," but an opinion from more experienced…
-
1
votes0
answers303
viewsValueerror: could not Convert string to float
Hello I’m trying to make an application in Tkinter/python and I can’t get the code to return the result of the calculation. the code created is the following: from tkinter import ttk from tkinter…
-
1
votes3
answers184
viewsFunction to duplicate a Python list
Guys I have this list: lista = [['10616558', 0], ['2856466', 1], ['9715350', 2], ['9715350', 3], ['9715350', 4], ['10720706', 5]] The first element is any string, and the second is an index. I need…
-
1
votes1
answer1875
viewsRun "Procv" on a Dataframe Pandas
I have a Dataframe in pandas containing a listing with values similar to these: a e r 0 88 6 -496 1 8 2 -188 2 76 5 -482 3 78 4 24 4 19 1 -346 5 40 1 -346 6 61 0 -224 7 79 1 -346 8 64 4 24 9 86 0…
-
1
votes1
answer48
viewsWhat is the appropriate style to write in Python?
What standard to name classes, methods, variables, etc., in Python, I thought just like in Java was Camelcase, but recently I heard to use snake_case. Is there any specific Python pattern? Which of…
-
1
votes2
answers83
viewsWhy do we use parameters/arguments in functions?
If a function can see environment variables, that is, it can see variables defined in the main program. Why we pass parameters and arguments to this function? In the example below, I wrote an…
-
1
votes1
answer167
viewsPlot graphing of an algebraic expression in python
I’m trying to plot a chart of an integral I solved, but it’s giving error : from sympy import * from sympy.plotting import * %matplotlib inline r=Symbol('r') e=Symbol('e') r=(1,10,100)…