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
answer1847
viewsHow to save the obtained medias in a dataframe, in a new column containing the averages of this dataframe using pandas?
Good night, I have a problem trying to save values of the average of a df, in a single column. An example of how I wanted you to stay was: Dataframe In this first part, I just opened my dataframe…
-
1
votes0
answers304
viewsPass parameter in URL
I am using the code below to search in google latitude and longitude based on the address, I would like to know how to pass to the URL the address in parameter form? The code below works perfectly,…
-
1
votes3
answers3324
viewsIgnore if it is uppercase and lowercase in the string
n1 = input('Qual é o seu bolo favorito?') if n1 = 'Bolo de Chocolate': print('teste123') If the user writes "Chocolate Cake" all in minuscule or all in uppercase, it will happen not to enter the if…
-
1
votes1
answer1266
viewsHow to add elements to the tuple using a function?
def funcao(): int(input('insira um número:')) tupla = (funcao(), funcao(), funcao(), funcao()) print(tupla.count(9)) print(tupla) insira…
-
1
votes0
answers853
viewsTypeerror: importPoisson() takes 1 positional argument but 2 Were Given
I am trying to import from an external file some data to be able to generate a graph and such, but every time of this error, follows my code: They may also say bugs you found in my code that can be…
-
1
votes1
answer1784
viewsPandas: Create multiple columns in Dataframe
I have a spreadsheet with the following information: NUM_LEGISLACAO DSC_URL ... COD_TIPO DSC_TIPO 0 323/1895 NaN ... 2.0 CONCRETO 1 2.269/1896 NaN ... 2.0 CONCRETO 2 2.397/1896 NaN ... 2.0 CONCRETO…
-
1
votes1
answer299
viewsBag of words in Python
I have a news dataset and I want to separate them between two classes. For this I thought about using Bag of words, but I’m not getting it with Sklearn. I tried the following: #Bag of words from…
-
1
votes2
answers2443
viewsHow to add the main diagonal of a python matrix?
I am developing an algorithm and I want to know if there is a command to add the main diagonal of an array in Python
pythonasked 6 years ago user129775 41 -
1
votes1
answer436
viewsFLASK - Changeable in template
I passed to the template a variable and need to change (in the template) the value of it. Ex.: in the controller: return render_template('index.html', start_code = start_code). I need to change…
-
1
votes1
answer2424
viewsrequests.exceptions.Sslerror: Certificate Verify failed
I’m having a big problem with Django requests. In the last few months I upgraded to version 2.0 of Django, and I’m updating all libs. I noticed that this impacted several scripts that I had, mainly…
-
1
votes2
answers3000
viewsPrinting data from a Python dictionary
How do I print the data of a dictionary each in a column? For example: lanchonete = {"Salgado":4.50, "Lanche":6.50,"Suco":3.00,"Refrigerante":3.50,"Doce":1.00} for m in lanchonete: print (m[0]) I…
-
1
votes1
answer577
viewsTimefield presentation format in Django
class Passagem(models.Model): inscricao = models.ForeignKey(Inscricao, verbose_name='inscricao', related_name='passagem', on_delete=models.CASCADE) hora_passagem = models.TimeField('Tempo',…
-
1
votes0
answers66
viewsGenerate pseudo-random numbers
Featuring a pseudo-random number generator that generates a sequence of numbers X1, x2, ... in the range [0,1]. How to turn these numbers into Y1, Y2 numbers... in the range [-11, 17]?
-
1
votes1
answer200
viewsError running PIP command on Docker
I have a python project that runs inside a Docker. When the image (Build) is mounted rele da um RUN pip install -r requirements.txt but when it executes the command returns a connection error.…
-
1
votes1
answer265
viewsStandalone Python software ( .exe file) for non-python machines with GUI and Tkinter
I am developing a software using Python 3.6.5 and I need to run it on machines that do not have python installed. It contains some libraries for machine Learning and access and excel to MS. I have…
-
1
votes2
answers469
viewsHow to access content from a json file?
I have a JSON file of information extracted from Twitter through the library tweepy, a piece of file content is as follows: Status(extended_entities={'media': [{'source_user_id': 3383675067, 'url':…
-
1
votes1
answer105
viewsPoorly formatted XML
I’m trying to read some XML files with the Element Tree of Python, but one of them, when I will do the parser give me that mistake: xml.etree.Elementtree.Parseerror: not well-Formed (invalid token)…
-
1
votes0
answers24
viewsError loading a video and creating an object in Django
My function in Django will receive a video from my site, is working normally. So I created the function create: def create(self, request): Video.objects.create(file=request.data['file'],…
-
1
votes1
answer113
viewsTypeerror: send_email() takes Exactly 1 argument (0 Given)
I have a code and I need to use threads, but always how I run the threads gives this error. import pyHook import pythoncom import os import threading import time import tempfile import datetime…
-
1
votes0
answers217
viewsHow to install dependencies for an application in Heroku?
I have some problems to deploy my app in Heroku. After adding the pipefile build, the application was deployed. However, I received an error message from the application on the website. The message…
-
1
votes2
answers1295
viewsCreate a frequency table based on another column in Python
Good afternoon, you guys. I have a data set in a file. csv, containing two columns: tweets and rating, where 'tweets' corresponds to any tweet searched on twitter and 'rating' corresponds to…
pythonasked 6 years, 5 months ago Gabriel Augusto 530 -
1
votes1
answer240
viewsConnectionrefusederror: [Errno 111] XML-RPC python
I’m trying to connect to a server using python 3 with xml-rpc, but an error is appearing every time I try to connect: Connectionrefusederror: [Errno 111] Connection refused This is my server code:…
-
1
votes0
answers66
viewsNodemcu does not receive the data as I send via UDP Protocol
I am developing a simple application, the goal is to simply send the reading of a sensor connected to an Arduino Nodemcu to a Raspberry PI, and perform a similar reading using Raspberry and send to…
-
1
votes1
answer152
viewsReturn more than one Django data list
I made a homepage using Jango, I am loading my slides and menus dynamically and it was perfect. I put both the menu and the footer through include and it worked 100%. Now I came across a problem,…
-
1
votes2
answers671
viewsSelect in Python (with BD: Postgres)
I am unable to select in the Postgresql database. Python 3. conn = psycopg2.connect(host="localhost", dbname='postgres', user='postgres', password=postgres) cur = conn.cursor() cur.execute("select…
-
1
votes1
answer58
viewsHow do I call file.Setter using Python to normalize the path name
Code: class Arquivos: @property def file(self): return self._file @file.setter def file(self, arquivo): if arquivo: self._file = os.path.abspath(arquivo) Calling for: Arquivos.file('usp/dados.json')…
-
1
votes1
answer99
viewsHow to name variables and organize them in the code in what goes beyond PEP 8?
Where I could find tips for naming variables, organizing code, etc.? For example, I have a class and it has several attributes, some depend on whether another attribute has been declared before, but…
-
1
votes2
answers697
viewsHow to add list values?
I have a list of lists, and I wanted to add up the various values for the Indice 3 of each list, but only if there is a certain string in this list. How can I do? For example I have this list:…
-
1
votes2
answers723
viewsAutocomplete doesn’t always work on Pycharm
I am starting the use of Pycharm, creating a test with Pygame. I realize that some Pygame methods do not appear in Pycharm Autocomplete. For example, if I want to put one pygame.mask.from_surface(),…
-
1
votes1
answer1633
viewsHow to click a link from a frame using Selenium Webdriver?
I’m studying a book Automate Massive Tasks with Python. I’m on page 317 that talks about Selenium Webdriver on the methods of finding elements on the pages. Table 11.3 - Selenium’s Webdriver methods…
-
1
votes1
answer2542
viewsAdding elements from a list to a dictionary in Python3
Good afternoon, I’m having trouble adding elements of a list to a dictionary. The list elements to put in the dictionary are: ['Joao', '83889023', 'Maria', '81944356', 'Marcos', '32258899', 'Ana',…
-
1
votes2
answers77
viewsHow to "reimport" an object from a Python module?
I wrote a module called mymodule.py who has the function def funcion(x): return x So I imported this function into a code like from mymodule import function and worked normally. Then I wanted to…
-
1
votes1
answer278
viewsBeautiful Soup - Remove a tag keeping Text
I have the following tags: <p>Projeto N <sup>o</sup> 00.000, DE 00 DE JANEIRO DE 0000.</p> I would like to remove the tag keeping the text. I needed it to stay that way:…
-
1
votes1
answer50
viewsError installing textract library with Conda
I am trying to install the python TEXTRACT library, but the following error is being made: Can someone tell me what I can do to fix this? Solving Environment: failed Unsatisfiableerror: The…
-
1
votes2
answers350
viewsFonts for standard Python functions
Is there any way I can figure out the algorithm behind functions like split() and in in Python, because in my faculty there are some forbidden functions.
-
1
votes2
answers56
viewsIf block is not well located, how to solve?
I did so, by the way he’s making a mistake, because door 80 is open and he returns as closed import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server = '201.27.188.138' port = '80'…
-
1
votes2
answers114
viewsError creating a simple Django table?
class Produtos(models.Model): #id = models.AutoField(primary_key=True) nomeproduto = models.CharField(max_length=50, blank=True, null=True) quantproduto = models.CharField(max_length=30,…
-
1
votes2
answers538
viewsAbout the structure of the Sorted function, how does it work?
The instruction below is done as many times as the vector size sub. What is the result of this instruction? sorted(sub, key = lambda x : size(x) ) Where x are the values from 0 to 31 inclusive and…
-
1
votes1
answer104
viewsTry-except, Indexerror, Alternatives to fix the error
I’ve got a college job to do, in a way I finished it, but with a few tricks I wanted to set up and make the code less confusing and so on. Operation of the programme: Basically it creates a 600x400…
-
1
votes1
answer92
viewsLogic of a neural network implementation
Hello, Good Morning I implemented a network, and it has the following matrix, where f(x) is an input vector (Matrix 1,139), the Phi matrix that has dimension 1,20 (20 due to the number of signals I…
-
1
votes2
answers220
viewsFlask Sqlalcheny Typeerror: 'Fermentables' Object is not iterable
In the model FermentableTypes: class FermentableTypes(db.Model): __tablename__ = "fermentable_types" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50)) desc =…
-
1
votes3
answers8133
viewsCount number of elements from a python list
I have the following list: lista = [ 'A','B','C','D'] I want you to count the number of elements up to a certain point, I know if you do len(lista) will count all the elements but what I want is for…
pythonasked 5 years, 11 months ago Arthur Carvalho 23 -
1
votes0
answers29
viewsMultiple search factors in an html file with variable parameters
Good morning, everyone. Needed to search by the name of the presidents of brazil, in html files. I created a json with the names of the presidents to facilitate. Follows the code: # !/bin/env python…
-
1
votes1
answer403
viewsApplication problem for stopwords and accents filter
Good morning, I’m trying to develop a simple Python algorithm for removing stop words from texts, but I’m having problems with words that have accents. The Code is as follows:: import io from…
pythonasked 6 years, 5 months ago Gabriel Naslaniec 19 -
1
votes3
answers665
viewsHow to turn content from a file into a dictionary in Python?
Guys, I have a file and I’m taking the contents of it and adding it into a variable. The contents of the file and the value of the variable is like this: NAME=Maquina01 ID="MAQ 15478" version=08 I’d…
-
1
votes1
answer150
viewsFlask Sqlalchemy : Keyerror
I am trying to create a database relation between the Article, Author and Category class, when trying to create an Article class object I get the error "Keyerror: "article" referring to the line…
-
1
votes2
answers15237
viewsHow to remove accent in Python?
In R I would accomplish this way iconv('Arapeí', to="ASCII//TRANSLIT"), so, there’s some simple way to do this in Python?
pythonasked 5 years, 11 months ago Márcio Mocellin 1,443 -
1
votes3
answers7344
views -
1
votes1
answer4261
viewsLimit Python number input 3
Using the following code I want to limit from 0 to 2000 the number that can be informed by the variable in a import collections num = int(input('Digite um número inteiro: ')) #Inputar número inteiro…
-
1
votes2
answers128
viewsHow to handle an address base
I have a database where the CPF is the PK and there is address information (such as zip code, street, number, etc). I would like to find people who live in the same residence, comparing street and…
pythonasked 5 years, 11 months ago Davi S. Santana 11