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
answer442
viewsPython - Typeerror: int object is not iterable
This is my code: import csv def gravar(nome,idade, sexo): with open('cadastros.csv', 'w') as arquivo_csv: colunas = ['Nome', 'Idade', "Sexo"] escrever = csv.DictWriter(arquivo_csv,…
-
1
votes0
answers58
viewsUse R inside a . ipynb
Hello! I have the following question: I need to use the following R packages for academic work: BETS (https://cran.r-project.org/web/packages/BETS/index.html) getDFPdata…
-
1
votes1
answer51
viewsResolve syntax error by pressing enter on keyboard without typing anything
Good night, you guys. My first post, I’m inciante and it may seem like a silly question but it’s keeping me up at night. I appreciate the help. In the code below, when pressing enter without typing…
-
1
votes0
answers62
viewsIf Else being ignored
I’m starting now on programming... I drove the Bugger and noticed that the if/else (# TKINTER RESULTS GRID) is being ignored, finishing the code without any error in the console. I tested some…
-
1
votes0
answers82
viewspython with redis
Good night, I’m trying to make a simple messaging application that unites Python with Redis, I was able to connect to the database in a simple set/get, but I’m not able to do any hashing to…
-
1
votes0
answers30
viewscreate a new dataframe with another
I have a dataframe with (1242 Rows 325 Columns) of it I make a correlation ". Corr()" which results in (325 Rows 325 Columns) this code shows me the 15 smallest correlations of the lowest value for…
-
1
votes1
answer308
viewsOrganizing code within __init__.py
I’m having trouble organizing my code. Ex: I would like to put generic functions, as pro example those that deal with reading a configuration file in only one place (read that the __init__.py is…
-
1
votes3
answers444
viewsDifferent results when using != or > in loop condition
I was doing Python exercises and came across the following problem. Assuming that the population of a country A is on the order of 80000 inhabitants with an annual growth rate of 3% and that the…
pythonasked 4 years, 6 months ago Magno Leal 47 -
1
votes1
answer85
viewsPython dictionary
The code below should count the words of the text and at the end show the amount of times each word appears in the text. I’m using the anaconda’s Spyder (Python 3.7). texto = """Caso tenha o estigma…
-
1
votes1
answer249
viewsCreate permissions on Django
I was trying to create a permission for my template but I couldn’t. I did some research to know how to do it and I’m not getting it. basically would like a permission similar to what Django has for…
-
1
votes0
answers228
viewsPrint shows no result displays "Typeerror: 'float' Object is not iterable"
I am making the code of a video lesson of Tensorflow but my code for more q is equal does not give the same result Everything that appears in the terminal: Windows PowerShell Copyright (C) Microsoft…
-
1
votes1
answer30
viewsBug in Python Whirlpool library
I installed the Whirlpool library in Python 3.6.5 and Python 2.7.9 to compute hashes with it. However, she presented an unusual problem: in conjunction with other libraries, it works, and when it’s…
-
1
votes1
answer76
viewsRename python files using Excel list
I am trying to perform the following function: Rename a list of files according to their modification date, from the oldest to the newest. The name of the files I have in an Excel list and the…
pythonasked 4 years, 5 months ago Gabriel Linard Ferrari 11 -
1
votes2
answers69
viewsMake sure the entry doesn’t happen again, numerically and within a range?
I am programming a game of old. When the user chooses the house where he will mark his symbol (X or O), I need to ensure that: The input value refers to an empty box (which has not previously been…
-
1
votes1
answer36
viewsHow do I count how many duplicate lists there are in a python numpy array?
Hey, guys, what’s up? I am new to the machine learning study and I come here to ask for a help on how I can proceed to count how many sub-lists have the same value in an array in python numpy as the…
-
1
votes1
answer442
viewsSet decimal numbers in a string list - Python
I hope you can help me! I am on a project where I am creating some Graphics for a system that is used by people from various countries. Because of this, I created a function called formatC that,…
-
1
votes3
answers84
viewsFind largest element index in the list
I am putting together a code that creates a list with 3 items of purchase, and within this list some tuples with the names of the products and the respective prices. I want to find the lowest price…
-
1
votes1
answer193
viewsConsolidate . csv files with Python
Good Night, please help me with the question below? I am developing a program that reads all csv’s with the same content of a folder and consoles them in a single file, disregarding the first line,…
-
1
votes2
answers38
viewsSecret Word Preview Does Not Update - Hangman Game
I’m testing the following code: #Jogo da forca #Funções def cls(): import os os.system("cls") def check_letra(letra): for letras in palavra: if letra == letras: return True def palavra(): p_N = True…
-
1
votes1
answer769
viewsXpath with Python - Pick up text after tag in a div
I’m trying to get a text after a tag that’s inside a div, in an html. The problem I’m having is that I’m not getting the text, just an empty string. I’ve looked elsewhere and I haven’t seen anyone…
-
1
votes2
answers72
viewsAccept entry with only 1 digit
I would like to know a way to accept only the entry with 1 digit. In the case below: 1, 2 or 3. Entries of type 0001, 01, 0002. (with zero left) was not valid (presented an error) and returned to…
pythonasked 4 years, 5 months ago Camila Cavalcante 39 -
1
votes0
answers90
viewsSeparate related models in Sqlalchemy
I have a model of relational tables: models/Base.py from collections import OrderedDict from src.config.database import db class Base(db.Model): __abstract__ = True models/Model.py from .Base import…
-
1
votes1
answer88
viewsPython script that generates a main diagonal character square
I am trying to make a program that given a value, generates a "square" of n rows and n columns that has characters : in the main diagonal positions and the characters + in other positions. For…
-
1
votes1
answer113
viewsHyperbolic cosine approach - Python
I have a little exercise to do: compare the result of the Cosh(x) approximation by Taylor series with the function you have in the Python library. The hyperbolic cosine Taylor series is: Cosh(x) = 1…
-
1
votes1
answer61
viewsHow to iterate a list in Flask
I have this code in Flask (which uses the Jinja2) {%block content%} {% for i in posts %} {% set x = x + 1 -%} <p style="border: 1px solid black; padding: 5px 5px; border-radius: 5px;">{{ i[x]…
-
1
votes1
answer149
viewsHow I treat a table in html as if it were a form
I am developing in Django an application for procedural research and it would be made based on excel spreadsheets. I found on the internet tutorials to select the table rows, however, I do not know…
-
1
votes2
answers528
viewsApply dynamic filter to a dynamic dataframe in Python Pandas
TL;DR Does anyone know how to apply a filter that will sum the values of a column of a dynamic table? The problem Well, I’ll show you the Dataframe first, it’ll be easier to explain. dados =…
-
1
votes0
answers80
viewsFunction that works on Edit/Django but does not work on the/Django wiki. Why?
I’m trying to make a feature to edit wikis. When I enter Edit/Django it returns me all right, but when I enter the wiki/Django, for example, where you have the edit button, it returns this error:…
-
1
votes2
answers619
viewsModifying a Python file without losing the current content
That doubt is a continuation of this here. I have a very large TXT file (about 6GB), each line being 1,300 characters, and I am manipulating these lines, as an example, I will use these three lines…
-
1
votes2
answers326
viewsRegex to capture links from sites specific to an HTML page
My goal was to make a Rawler web that found links (in many ways, but starting with http/s) in the HTML page of a site, I used requests and regular expressions, a part of the code went like this:…
-
1
votes2
answers104
viewsInsert text into its proper cells - Python
Hello, my friends I am developing the code so that I can clean and organize the data (as shown above) and one of the best ways was to insert the data into a file CSV so that later I could return it…
-
1
votes2
answers351
viewsindex 5 is out of Bounds for Axis 0 with size 1
Well, I have this code, I want it to take specific columns of 3 sheets and join in one, ams is giving the following error: index 5 is out of Bounds for Axis 0 with size 1 import pandas as pd Corp =…
-
1
votes1
answer110
viewsHow to pull a Foreignkey from the models on Django?
Hello I am developing an application and I have a problem, if someone knows how to solve. I created the following models: class Cliente(models.Model): user = models.OneToOneField(User,…
-
1
votes2
answers66
viewsobject1 += object2 is different object1= object1 + object2 in python(3.8)?
objeto1 += objeto2 and objeto1= objeto1 + objeto2 give different results even though the two forms seem equivalent. Could someone explain to me what I’m not realizing? class f(): def…
-
1
votes1
answer31
viewsIterating over list with B Soup
I am trying to realize web Scrapping of a list of episodes of a series with BS. I mounted the structure below: #Importando todos os módulos import bs4 from bs4 import BeautifulSoup import…
-
1
votes1
answer73
viewsI can’t get the None result out of this code
I’m trying to pull this one out None, I’ve already put else, I’ve already put add2 and then I defined add = add2 but I haven’t been able to get it out. How does it look: Which fruit do you want to…
-
1
votes1
answer548
viewsHow to access folders and copy files in Python?
Hi, I’m new to Python. I have a folder "MAIN". Inside this folder there are several other folders. In these folders I have the file "IQ.jpg". I wonder how I do to access all the folders inside the…
-
1
votes1
answer399
viewsSet the colors of a point on a matplotlib scatter chart
I am handling data received from an Arduine from a .txt. In the code, I Gero 4 arrays (X,Y,Z and F), where X,Y and Z are coordinates and F is the signal strength. I would like to plot the 3D graph…
-
1
votes1
answer42
viewsFlask-Migrate in Factory Standard - App error not found
Hello, I’m trying to run the remote: flask db init, but the traceback returns: main/app/Extensions/migrate.py: from flask_migrate import Migrate from main.extensions.sqlalchemy import db migrate =…
-
1
votes1
answer128
viewsFix badly formatted JSON
I receive a totally non-standard JSON from a customer. And as always, the customer is always right :-( JSON arrives as follows: { dominio:casadasloucas.com.br,…
-
1
votes2
answers69
viewsOFF - Is it possible to print a list value by passing its index?
In the code below I,when I come out of the while,I print the athlete jumps data, along with the average of the same. In the loop for,I print out all the jumps of the athlete, 'Cause I wanted to do…
-
1
votes1
answer58
viewsProblems instantiating objects in python
I’m new to programming, but I just came from Java and I’m migrating to Python.. To start I created a simple Person class with 3 attributes and tried to instantiate it to see the syntax, but I just…
-
1
votes2
answers53
viewsHow can I associate typed and stored values in an array to a menu option?
How can I associate a range of values from 1 to 6 to each of the options in the OS menu that I have in the list? My idea is that when I type three times the number 1 for example, this counts as…
-
1
votes0
answers23
viewsGeostationary projection of cartopy produces displaced data
Hello! I am trying to plot a geostationary satellite data (MSG-SEVIRI) using cartopy projection ccrs.Geostationary. The data format is grb. However, my code is generating a wrong result. The data…
-
1
votes1
answer41
viewsError trying to print an array with larger elements from two other matrices - 'int' Object is not subscriptable
In my code, I create two matrices, and compare the elements of the two in each position. The largest element at each position is selected and placed in the third matrix. When I finish all the…
-
1
votes3
answers5809
viewsHow to fix "Valueerror: invalid literal for int() with base 10: '' - Python?
Summary of my program/ problem: I need to draw at an ATM between 10 and 600 reais. When running the program, any value above 100 it prints correctly, but if I put any value below 100 it presents the…
-
1
votes1
answer46
viewsHow to not return only the last sentence in for loop?
I’m creating a for to store the data of each event in a sentence and then join it in a string. However, I only get a return of the last value. qtd_eventos = int(input('Informe a quantidade de…
pythonasked 4 years, 3 months ago Lucas Zancheta 25 -
1
votes1
answer827
viewsHow to run Python function every 1 minute, without using time.Leep()
Is it possible to run a function every 1 minute without using the.Sleep() team? I need to use the computer clock so that, whenever the clock reaches 1 minute, the function is executed. The.Leep()…
-
1
votes1
answer97
viewsReturn a specific XML field
I am creating a program that aims to obtain data from an XML, I am using xml.etree.ElementTree for this, but I’m not able to create a for to call the tags cEAN and qCom. The XML used: <nfeProc…
-
1
votes1
answer95
viewsStore return of XML
I have a return of an XML that is a loop (because it’s the only way I know how to call back) but in XML I have two det, det nItem="1" and det nItem="2" which are 2 products, inside them is the tag…