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
votes3
answers64
viewsoptimize Camelot large pdf files
Good afternoon! I use Camelot to extract data from PDF files (bank statements to be more accurate). However, I have a PDF file with more than 5000 pages, and Camelot is a bit slow. I decided to…
-
1
votes0
answers57
viewsScraping on instagram
Hello, I would like to ask for a help, I’m wanting to do a scraping on Instagram to be able to analyze personas and extract some data as tags most used by people who follow a certain someone, I took…
-
1
votes2
answers177
viewsHow to find the umpteenth occurrence of a substring?
I need to do a function that takes as input a string, a letter, and a number that indicates the desired occurrence of the letter (1 for first occurrence, 2 for second, etc). The function needs to…
-
1
votes1
answer46
viewsInverting variables (Python)
I know you can do it in other ways, but I’ve done it limited to ifs. I wonder why I’m reversing the results in the last part of the code. from random import randint pedra, papel, tesoura = "1", "2",…
-
1
votes0
answers55
viewsValueerror: Setting an array element with a Sequence
I can’t fix the error that appears in the code. I have a rotational matrix, trying to calculate rotational forces, that is, radial, axial and tangential force. Ft2 = np.zeros([janelaanalise,]) Fr2 =…
-
1
votes1
answer165
viewsRegex to catch files with certain characters in the name
I was in charge of creating a code that navigates to the server folders looking for files with wrong nomenclature (Accents, spaces, punctuation and special characters..) where I have broken through…
-
1
votes1
answer52
viewsHow to do k-fold validation when I change the cut-off of the model?
When I report metrics from a machine-Learning model I always use k-fold validation. Here’s an example of implementation: import pandas as pd import numpy as np from sklearn.model_selection import…
-
1
votes2
answers58
viewsHow to add specific intervals of several lines?
I have a file with several lines and I want to add a certain range considering all lines. To simplify, I took as an example: AAA0000011111000090011 BBB0000011111000080011 CCC0000011111000070011…
pythonasked 3 years, 10 months ago GABRIEL ANDRADE QUEIROZ 21 -
1
votes1
answer93
viewsPython - Count the number of incidences of an event in a time window
I have a table with basically names, dates and groups like: Index Name Date Group 1 Joseph 01/01/2020 To 2 Joseph 01/01/2020 B 3 Joseph 03/02/2020 To 4 Joseph 01/03/2020 To 5 Joseph 01/05/2020 To 6…
-
1
votes1
answer44
viewsPython base 64 for image
Personal I’m taking 1 photo from the database but it’s coming as base 64 , that I need it to turn image again to be able to locate on the screen , how do I turn the base 64 into Bites again? I tried…
-
1
votes0
answers32
viewsScrapy - Search for items in form
I am very beginner in the subject, can you help me? I am testing Spiders to seek bids. But I can’t return the items through the form. I have the code below example: import scrapy from scrapy.http…
-
1
votes1
answer40
viewsgraphics generation automation with Seaborn is creating repeated colobars
I have the following problem: I have a database consisting of a 2D array of measures that vary over time. For each time measure, I need to generate a color map chart to be merged later into a gif or…
-
1
votes2
answers67
viewsIs there a better way to deal with relational and non-relational databases in the same project?
I am refactoring a code, where I process some data and send it to a database. I have two versions. One where I use Mongodb and the other where I use Mysql. But I’d like to put the two versions…
-
1
votes0
answers38
viewsHow to get averages of past occurrences relative to the line in question in a dataframe (Pandas)
I’m building a predictive model to rank football matches, the model uses goal averages in the separate teams' season between bosses and visitors, I’m averaging the whole year, but in early season…
-
1
votes0
answers34
viewsError 403 - Google API - Classroom
I have a python script that creates and links students from a certain list of Class room classes in Google via API. The problem I’m having is the following, the student and inserted in more than one…
python django google-api google-api-client http-status-code-403asked 3 years, 9 months ago Romulo Ferreira Mesquita 7 -
1
votes1
answer77
viewsCumulative sum of data in new python column
Hello personal I have a dataframe with input and output data per day my need and add to that dataframe a cumulative column are daily entries and exits so in excel I would have the following code…
-
1
votes1
answer26
viewsError running makemigrations on my Django project
I am trying to run makemigrations on my Django project but it is returning error saying that the argument default is not expected or something like, follows part of the error: TypeError: __init__()…
-
1
votes1
answer19
viewsProblems writing converted uuid from Binary(16) to csv file
From a query in MySQL I receive lines with the field in the format binary(16) of MySQL. I do the conversion using lib uuid and try to insert into a file csv. Does not write in format uuid in the…
-
1
votes2
answers97
viewsHow do I filter a Dataframe row by knowing a String value from one of its columns?
Let’s say I have at hand this dataframe And I know that a specific value inside a column called "Code", contains a String that I will call "mxrf11", in the whole dataframe will not have another name…
-
1
votes2
answers195
viewsHow to return a list where the size is set according to a number typed in the python input?
I would like the code I wrote to return a number of tuples according to the value entered in the input, for example, if the input is 3, the return will have to be 3 pairs of tuples. The following…
-
1
votes1
answer37
viewsJoin two columns with different dates
I have two dfs: 1 - Quotation of a share of the month of January-2020 (23 lines) 2 - Quotation of a share of the month of January-2021 (23 lines) I need to put all this together in a single date…
-
1
votes1
answer50
viewsHow to access the index correctly for data in the same file?
I have a file txt file.: >gb:KX262887|Organism:Zika virus|Strain Name:103451|Segment:null|Subtype:Asian|Host:Human GTTGTTGATCTGTGTGAATCAGACTGCGACAGTTCGAGTTTGAAGCGAAAGCTAGCAACAGTATCAACAG…
-
1
votes0
answers28
viewsHow to call data from a dictlist into code in the form of Checkbutton in python Tkinter
Reformulating everything, I created a new file from scratch called "dict_list_codigopenal.py", he is responsible for taking the file "cdp.csv" and read as spreadsheet, transforming into a Dict list.…
-
1
votes1
answer51
viewsCreating and installing my own packages
Hello. I’ve only been learning Python for a short time. I’m now trying to create my own packages. This helps organize the code. But I had a question: would anyone know how to install my packages so…
-
1
votes1
answer63
viewsHow to change duplicate data in a dataframe?
I am trying to automate a process that I do manually in excel. That is to extract the company’s employee base from excel, select some specific columns (because the file is too large), remove certain…
-
1
votes3
answers253
viewsHow to resolve "Valueerror: max() Arg is an Empty Sequence" error when the list is empty?
This error appeared when I was testing my program, more precisely when the values of input do not satisfy the conditions imposed: n = int(input()) listaVelocidade = [] for _ in range(n): velocidades…
-
1
votes1
answer50
viewsWhen passed by class, numbers do not come out random
I’m creating a neural network, and now I’m doing the part that would create the population to be trained, but I’m not getting a randomness. I just don’t understand it and I don’t know how to get…
-
1
votes0
answers51
viewsHow to apply Transform to two variables in pandas?
I would like to create a new variable which is the scalar product of two variables in a sub-group of my dataframe. I know that when I want to create a group-level variable, I can use the method…
-
1
votes0
answers17
viewsMixin Django Class Based View Python3
Good morning guys: Problem = add a new functionality via a mixin in Jango for a CBV. reason = I want to create two records in two different records. Trying = class CreateUserMixin(object): def post2…
-
1
votes0
answers21
viewsHow to make a Python script run at an automatic time?
Hi I made a script to send messages in Skype: from skpy import Skype sk = Skype(username, password) # connect to Skype sk.user # you sk.contacts # your contacts sk.chats # your conversations ch =…
pythonasked 3 years, 9 months ago user219931 -
1
votes0
answers56
viewsDjango Model Queryset - Insert record if it does not exist with only one query
I’m starting to use Jango and its ORM and I came up with a question. How can I check if the record exists in the database and if it does not already exist? This with only one query to the database.…
-
1
votes1
answer59
viewsFill graph line in Python and change axis numbers to strings
Good afternoon. This is the first time I’ve ever done a 3D graphic in Python, in Anaconda’s Jupyter Notebook. The goal is for the chart to look like this formatting: My code is this:: import numpy…
-
1
votes1
answer96
viewsHow to sort a list of user-provided words using Python?
I’m trying to create a program where the user informs the list of words to put in alphabetical order, only when I put the program to run, it worked normally, but the list he gave me was listing…
-
1
votes0
answers32
viewsError Pivot pandas Tables celuas merged
Hello, I have a table in pandas and need to transform, I believe using the pivot, from a certain column Month Codigo COD 1 COD 2 0 NaN Date 1 07/05/2018 01/01/2019 1 NaN Date 2 NaN NaN 2 05/2018 0.9…
-
1
votes1
answer30
viewsDjango: How to prevent date field conflicts in admin
In a record of a Vaga inside the Django admin I have two fields: data_inicio and data_fim. But I wish it wasn’t possible to put one data_fim less than data_inicio, and I don’t know how it can be…
-
1
votes3
answers58
viewsI cannot convert mongodb files to json in python using bson in python
I am trying to work with data from an online database. I am able to do the requisitions in the right way. But when trying to convert the downloaded data using the bson package, I get a string object…
-
1
votes2
answers185
viewsBeautifulsoup: Catch text inside table
I’m trying to get specific values within a table, I have a similar code that I already use in the same way in another unique table structure within html, the problem and that I can’t get the text of…
-
1
votes0
answers16
viewsError installing Pip install mod-wsgi-httpd
I am trying to install the mod-wsgi-httpd package via the Pip command, but am getting the following error: ... File "c:\python39\lib\urllib\request.py", line 641, in http_error_default raise…
-
1
votes1
answer57
viewsI need to inform the user if it contains a registered user with this same user name
Opa, then, I need to inform to those who are using the program, if you already have any user registered with this name and inform the age of the same contains in the list that must be registered…
-
1
votes3
answers326
viewsFind a button using Xpath Selenium
I am trying to find a button using the webdriver + Python Selenium, the button code is: <button class="w-full h-14 pt-2 pb-1 px-3 bg-accent text-dark-1 rounded-full md:rounded select-none…
-
1
votes0
answers35
viewsOperation I/O 'Block' loop?
Greetings friends, I come here to ask for help in relation to doubt about the operations of Request and with the operation Open. As far as I know and read, the operation file_request =…
-
1
votes1
answer41
viewsInclude a character in an excel python values
I have a dataframe whose column has 12 characters. However most on the left are zeros and at the end of it I have the values. Examples: I’m trying to include a comma or dot before the last 2…
-
1
votes0
answers20
viewsSend Password Parameters to execute a command Via Paramiko - Python
Good afternoon, I am with a project that copies a file from a server and plays it in a directory mapped to collect information from the file , but when connecting and executing the command to copy ,…
-
1
votes1
answer54
viewsMy dataframe skips a line in excel when Columns receives more than one line (pandas)
I’m trying to make dataframes and pass them to excel, but when I do a dataframe with more than one header line, it skips a line before plotting the data in the spreadsheet (leaves an empty line). It…
-
1
votes0
answers29
viewsHow to filter lines if column is without variable name - Python
I have some excel data that I imported into a Python dataframe (Base_Eventos). I need to summarize a variable (idPartida), then use: Base_Eventos.groupby (by = 'idPartida '). count() Only the result…
-
1
votes2
answers99
viewsfind intersections in two graphs in python
I have a very simple but functional code. It obeys two mathematical functions, testing different values of x and returning the coordinates of the point if the result of the two functions is the same…
-
1
votes2
answers51
viewsWhen one Function terminates the other ends also multiprocessing asynchronous functions
I’m using the library multiprocessing, running two def at the same time, but I want to finish one of the two def the other that is still running also end in the middle of the process. Example: from…
-
1
votes1
answer29
viewsPromote convolutional filters in tensorflow
I’m trying to visualize the filters of a neural network and I’m not getting to understand how to display the filters as images. I’m currently using the CIFAR10 base (32x32 color images). I’m using…
-
1
votes1
answer47
viewsHow to make a formatted print?
Hi. I’m sorry about the basic question, but I started dealing with python a week ago. I’m writing a program that records candidates' votes in a binary file. But, at the time of displaying I am not…
-
1
votes2
answers88
viewsIntersection of words with Python dictionaries
Hello! In Wendel Melo’s book, Introduction to the Python Programming Universe, I tried to do the last exercise, but I’m not getting it. Enunciation: Make a program that reads three user strings and…