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
answer37
viewsDrop values from a dataframe based on a boolean value
When I read a CSV file, these are the first 5 lines: Shape Reported Time 1 OTHER 6/30/1930 20:00 3 DISK 6/1/1931 13:00 4 LIGHT 4/18/1933 19:00 5 DISK 9/15/1934 15:30 6 CIRCLE 6/15/1935 0:00 I want…
-
1
votes2
answers101
viewsDoubt about value extraction using Soup.findAll() in Python
Good afternoon to all. I am studying python and learning to extract data on websites and to start this learning I am creating a program that will extract the data from the lotofacil site of the…
-
1
votes1
answer74
viewsHow to generate a new list from another Python list?
I’m having trouble performing list operations in Pyhton. I have a list of values. frequencia = [1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,…
-
1
votes0
answers31
viewsHow to define Custom Loss Function?
Hello, I am trying to make a custom Loss Function through the Keras Functional API and I am having problems with this implementation since I have never done anything like. I want to make a Loss…
-
1
votes0
answers49
viewsAPI access control using Flask JWT Extended
Hello. I am working on an API (Flask/Python) that should receive requests from an application (React-Native) and a Webapp (Flask/Python). For some requests you will need the login control. I am…
-
1
votes1
answer108
viewsHow to get binary code from a string without ASCII characters in Python?
I’m studying Unicode and encodings. I understand so far that Unicode is a key-value structure in which each character is represented by a number. Example: import string…
-
1
votes0
answers41
viewsDoes Pyqt5 monitor events asynchronously on Windows and synchronously on Raspberry?
Context I’m developing a program that uses Opencv4 to identify some metal fasteners, the program is relatively simple and uses in short color search contour filters, in Windows so far everything…
-
1
votes1
answer47
viewsWhy does the HTTP request response not recognize special characters?
Why when I make a request using Beautifulsoup in Python, my answer does not consider Latin characters? Code: import requests from bs4 import BeautifulSoup req = requests.post(url=…
-
1
votes1
answer36
viewsHow to use groupBy with pd. Cut?
I’m trying to perform a groupby with the pd.cut() function, but I’m getting weird results. I have the following columns: jul/16 Ago/16 R$ 34.252,00 R$ 52.000,00 R$ 33.850,00 R$ 33.850,00 R$…
-
1
votes2
answers231
viewsSelenium - Unable to login ( unsecured browser )
Hello, good evening, I am trying to develop a python web bot, using the library Selenium and webdrive_manager, but when I try to log in to my google account using the browser that the bot is…
python python-3.x selenium selenium-webdriver automationasked 3 years, 6 months ago Antonio Pacheco 27 -
1
votes1
answer44
viewsMerge lists based on key column value
I am converting 2 dataframes into 2 lists. And I will group them by the CNPJ_UF_MES column (always the 1st column of each dataframe. In the real example, I will join more than 2 dataframes. After…
-
1
votes1
answer89
viewsFilter Dataframe pandas with two or more conditions
I am creating a chart with dataset tips, for this I need to filter the data based on two or more conditions. My goal is to count the number of men, and the number of women. And also count only the…
-
1
votes2
answers58
viewsRecover database data on Django
My project is a simple table showing countries, number of covid cases, deaths and recoveries. By Django admin I have already registered two countries and now I want to recover this data and show on…
-
1
votes1
answer30
viewsInitial Form Django is not working properly
Well I am developing an application in Django and I am trying to use jquery with Django to make a request to Viacep to consult the cep that the person typed and left the focus of the field that was…
-
1
votes1
answer76
viewsHow to print in the same line in python?
The function print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False) has the argument end and by default end='\n', I know I change for end=' ' will print in the same line. But I am…
-
1
votes1
answer36
viewsNumpy copy method does not create a deep copy?
I’m taking a look at Numpy’s arrays and saw that method copy should make a deep copy array. When I create an array of strings or numerical values this seems to be true. However, when I create an…
-
1
votes1
answer63
viewsHow to align numbers on the left using str.format?
I’m studying about format strings and I’m not getting the same alignment behavior on the left with the minus sign (-) using the function format. What is the right way to do this using format?…
-
1
votes1
answer45
viewsUnzip. corrupted zip with python
I have the following situation, I need to unzip ". zip" files, the code I am using is this: from zipfile import ZipFile from tkinter import Tk from tkinter import filedialog as dlg from…
-
1
votes1
answer47
viewsSorted function referencing keys in a dictionary to define the sort criteria
dict = {'dc':20,'ba':10,'aa':5,'db':30,'za':1} dict_2 = sorted(dict.items(), key = lambda dict: dict[1], reverse = True) print(dict_2) When I place Dict[1] in the function argument I get the…
-
1
votes1
answer39
viewsword_tokenize creating tokens with only one character instead of words
When creating the list below, with the tokens of multiple texts .txt, the for loop tokenize the characters and not the words themselves: import glob import nltk l = [] for file in…
-
1
votes1
answer67
viewsCombination of a numerical list with limiter (Python)
I am generating all possible combinations within a list, but I have not found any that would satisfy all my needs, being them: Result in list format; Lists with repeated items are valid; Completely…
-
1
votes1
answer27
viewsHow to use PIL floodfill in python?
I am trying to color a bar using python’s PIL package. This is the original bar: I would like to color the entire inner part with just one color. I tried to use the floodfill for that reason: from…
-
1
votes1
answer29
viewsGrouping by several variables
I’m working on the base below, and I need to group the variable close, grouping the last day of each week, by month and year, the base I’m working on has data from 2005 to 2017, below I’m just…
pythonasked 3 years, 5 months ago Roney Wesley Galan 179 -
1
votes1
answer66
viewsUnboundlocalerror: local variable 'res' referenced before assignment - raster image scanning error (like numpy array)
I created a program that takes raster images (created in arcmap) and recognizes their polygons (their divisions). First, what I did was turn the image into a numpy array. Follow an example image…
python python-3.x array numpy image-processingasked 3 years, 5 months ago Sara Isabel Aleixo Perestrelo 13 -
1
votes1
answer25
viewsPython - append in the same Dataframe
I have the following code to extract data from the yahoo that works perfectly. My problem is that I wanted to insert all the data into a single table every time it enters the FOR it go add to the…
-
1
votes1
answer37
viewsWrite to a. txt file with for loop in Python
I need a file . txt to save the last generated serial, for the next time that file is executed to be read and continue sequencing. That is, if the last serial(serial2) generated is the number 6 I…
-
1
votes3
answers74
viewsPicking numbers from a string - python
How could I get just the digits of that string? <SCANNER A7899739503929> I’ve tried using the findall, but unsuccessfully it returns me several separate numbers: import re txt =…
-
1
votes2
answers35
viewsI’m making webscraping with python and can’t break a loop
I’m automating the search for gamer laptops on Amazon, which in addition to picking up the first page it picks up the next ones, but it gets to a point that won’t stop trying to pick up more pages…
-
1
votes0
answers40
viewsDoubts about python classes and attributes
I am creating a program in python and I have some doubts about the declaration of classes and attributes. I have two class files, one generated named dosps.py and another kpi.py Inside these files,…
-
1
votes1
answer32
viewsFrame one image within another
I’m having a little trouble implementing the following situation: Read a folder with multiple images; I have to read the images and resize each one to 720x185 resolution; I was able to resize the…
-
1
votes1
answer24
viewsValue_counts - Pandas - Dataframe - Zero Quantity
I have a dataframe with a column of hours and the other kind of relampago.I’m making a value_counts to count the amount of relampagos every hour the day. The value_conts is working, but there are a…
-
1
votes1
answer50
viewsCompile error using Selenium: Binary is not a Firefox Executable
I made the following script: #/usr/bin/env python3 -u import time import sys from datetime import datetime from selenium import webdriver from selenium.webdriver.common.keys import Keys from…
-
1
votes1
answer17
viewsHow do I make a window not close? Pysimplegui
I need to disable window options made in Pysimplegui and allow closing only if you hit the password in a text box. my code: sg.theme('DarkRed') layout = [ [sg.Text('Senha'), sg.Input(key='senha',…
-
1
votes1
answer49
viewsHow to unify by Python several repeated lines of an Excel file?
I have this spreadsheet in Excel, which is generated in the system by the pandas dataframe I can even generate the file, the problem is that it generates this way above. I need that, for example, in…
-
1
votes1
answer24
viewsThird axis and graph python
I need to make a graph that has 3 y. axes 1 on the left side and two on the right. I’m managing to plot them, but the ones on the right side stay one on top of the other. How to leave the side?…
-
1
votes0
answers20
viewsSearch dictionary element by Gherkin
I need to perform an automation, in which I need my code to read the information presented in Table by the Gherkin to select the option I presented inside a dictionary, which is in a file intended…
-
1
votes2
answers48
viewsReturn rows from a dataframe that are not in another dataframe
Basically, I have a Dataframe (Database) that contains all the data registered in my system: data = {"Id": ["01", "02", "03", "04",'05'],"Fruta": ['Maçã','Abacaxi','Banana','Laranja','Morango']}…
-
0
votes1
answer386
viewsMenu creation using Web2py?
I’m having difficulty creating menu on my site using the standard Web2py template, some hint and example? I tried to follow suit…
-
0
votes1
answer787
viewsPygame - Align screen in the center
People you have knowledge of how to align the screen of my game in the center of the desktop screen?
pythonasked 10 years, 8 months ago WPF Developers 13 -
0
votes1
answer462
viewsHow to set up Sublimerepl for Anaconda (Python)?
I installed Sublimerepl for execute the line or selection directly from Sublime Text 2. Meanwhile, in the same way as in this previous problem, Sublimerepl is not using Anaconda but another version…
python sublime-text-2 ipython anaconda sublimereplasked 10 years, 8 months ago Carlos Cinelli 16,826 -
0
votes1
answer1180
viewsSyntaxerror: can’t assign to Operator
I’m using the following code: Levels[track][level] > UnpaidMaxSkills[track] or self.inventory[track][level] += amount Only I get the mistake: Syntaxerror: can’t assign to Operator What might be…
-
0
votes1
answer342
viewsPython UI - How to Do
I wrote a simple program in Python, and I need to make a graphical interface for it, what are the options of GUI Builder today?
pythonasked 10 years, 8 months ago Matt Costa 345 -
0
votes1
answer655
viewsError in os.system() python
I have a script in python that needs to run other software multiple times, I’m trying to do this using the.system("command"), but this function always returns me -1 and does not work, I have tested…
-
0
votes2
answers306
viewsNotification data Pagseguro
I’m trying to integrate Pagseguro with this lib: https://github.com/rochacbruno/python-pagseguro But, I can’t access the notification data that Pagseguro sends me. I’m using the following code:…
pythonasked 10 years, 5 months ago Filipe Ferminiano 103 -
0
votes1
answer242
viewsHow to plot a graph when terminating a computer vision script on Raspberry pi?
I have a code using opencv Raspberry Pi and it is running a pattern recognition loop. In the end I close the script using "Ctrl + X" without any problem! I want to "stop" the graphical processing,…
-
0
votes2
answers119
viewsAttribute name referring to secondary key in a model in Django
I have a problem with an imported database for Django 1.6.5. In this database the columns follow the pattern: id_city, name, id_state and etc. However, Django did not handle it well leaving the…
-
0
votes1
answer891
viewsOperation with Factorials from thehuxley.com website
Input format: An integer x corresponding to the X of the equation and an integer n indicating a number of series terms, input ends when x = 0 and n = 0. Output format: A floating point number…
-
0
votes3
answers2578
viewsHow to read another program’s variable?
Guys, I am learning Programming and I would like to know: how do I read the value of a variable of another program (theoretically this would be without "awareness" of the program read, I do not know…
-
0
votes1
answer237
viewsCreate a scan window in MATLAB
I’m trying to create in Matlab a script that makes a sub-matrix (search window 3 x 3) go through a larger matrix looking for minimum values for each 3 x 3 cell chunk analyzed. When the script finds…
-
0
votes1
answer388
viewsUser Choices in Tkinter
Hello. I am trying to create a program of graphical interface using Tkinter(I learned a little while ago) and I wanted the user, when writing in the text input box and pressing the button he printed…