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
-
0
votes2
answers374
viewsBreaking string from a character
Inside my dataframe, one of the columns has information separated by comma, I would like to delete everything within the string after the first comma. Follow the code I’m trying to use: df_movies =…
-
0
votes2
answers665
viewsLoad multiple concatenated CSV at once in Python
Talk personal, quiet? There is an easier way to load . csv concatenated at once instead of doing the procedure below? z1 = pd.read_csv('arquivo1.csv') z2 = pd.read_csv('arquivo2.csv') z3 =…
-
0
votes1
answer1460
viewsImport txt files with pandas
I’m starting in the area of machine Learning, following a website that suggested the following initial model: import pandas as pd from sklearn import linear_model import matplotlib.pyplot as plt…
-
0
votes1
answer628
viewsAll data from a row in the dataframe is going to the first column using python pandas
I’m reading a CSV file with pandas on a dataframe, it turns out on line 10, all the data is going to the first column, this way: How can I solve this problem and separate correctly? I need only the…
-
0
votes1
answer961
viewsStoring Variable in a Python TXT File
Greetings,I made that algorithm CODE BELOW: from bs4 import BeautifulSoup soup=BeautifulSoup(html,'html.parser') for link in soup.select('div.sg-actions-list__hole > a[href*="/tarefa"]'):…
-
0
votes1
answer56
viewsWhy doesn’t he run my read() since I opened it for reading and writing at the same time
The code below allows me to write, but does not show me the content of what I wrote in the file with the read method() filename = input('Informe o nome do arquivo: ') filename += '.txt' arquivo =…
-
0
votes1
answer3453
viewsValueerror error: I/O Operation on closed file. when generating csv with python
My code is giving error of "ValueError: I/O operation on closed file." and I can’t find it in any forum, does anyone know what it might be ? Thank you. import json import requests import csv url =…
-
0
votes2
answers174
viewsProblem with input of more than one integer with input
I’m having trouble capturing the input of more than one integer into one input. Ex: numero = int(input('Digite o primeiro número aqui: ')) numero_1 = int(input('Digite o segundo número aqui: '))…
-
0
votes1
answer28
viewsoperatorArhythmic
Good morning, does anyone know what that vertical bar in python means? 4|3 = 7 12|4 = 12…
-
0
votes1
answer116
viewsProblem Reading Unicode python file
Guys I got my script : import sys search = sys.argv[1] ref_arquivo = open('C:/Zabbix/RelatorioErros.txt','r').readlines()[11:] for line in ref_arquivo: if search in line:…
-
0
votes1
answer146
viewsConvert . py files to . exe files
Hello, can anyone explain me how to convert an application in . py to . exe format and run in windows? I tried to use cx_freeze but could not. Is there any way to create a converter? Thanks.
-
0
votes2
answers770
viewsPYTHON - Typeerror: 'numpy.float64' Object is not iterable
Hello, I’m getting this error return while trying to run the following loop: for p in p: for q in p: if p != q: arrFreq.append(p - q) OBS: "p" is an array that contains frequencies of an audio. The…
pythonasked 4 years, 10 months ago Everton Marques 1 -
0
votes1
answer56
viewsPython error with object orientation
class DBAction(object): __conn = None __cursor = None __id = None def __init__(self, arg): self.__id = arg self.__conn = sqlite3.connect('clientes.db') self.__cursor = conn.cursor() def…
-
0
votes2
answers120
viewsBeginner in Python
I can’t find a way to check several variables at once. Look what I tried: Example nota1 = 10 nota2 = 20 nota3 = 30 for i in (1, 2, 3) if nota{i} == 0 print('É zero') In this case, there are many…
-
0
votes1
answer138
viewsHow to read two numeric values for a list in the same line in Python?
I know that to read multiple values by input on the same line you use "split()", and to add values to lists, some loop like "for" or "while"but I would like to know how to join both to be able to…
-
0
votes1
answer294
viewsWhy does my print command not work?
my print command doesn’t work at all, when I use it in pycharm it doesn’t work and when I do a script with Idle it doesn’t work either, but when I do with the python prompt it works. script asks…
-
0
votes1
answer129
viewsRead files in python
good... I have a file with the following things : if else ( ) ' " print and the following code : arq = open('system/commands.txt','r') arquivo = arq.readlines() for l in range(0,7):…
-
0
votes1
answer717
viewsExercise python read Dat file
I’m stuck on an exercise that I can’t think of how to solve. The exercise consists of a dat file that contains a line for each student in a class of students. Each student’s name is at the beginning…
pythonasked 4 years, 9 months ago Wesley Israel 11 -
0
votes1
answer2111
viewsHow to convert values into percentage of a "total" column into pandas?
Hello! I’m learning about Python and Numpy, but I’m having trouble working with percentages. Considering that the total column corresponds to 100%, as I do to obtain the respective percentages of…
-
0
votes2
answers74
viewsHow I see the code of an already interpreted html page
When I make a request in an HTML page with Python I get the source code , but if I access the page and go to see the code of the page by the options of developers I have there a totally different…
-
0
votes2
answers501
viewsI cannot install Tensorflow-GPU
I started learning about tensorflow recently and decide to trade for the GPU version, for being much faster, but I can’t, always gives the same error. Specs: I5-8400 GTX 1060 6GB Windows 10 Home 64x…
python importing machine-learning machine-learning tensorflowasked 5 years, 9 months ago Gabriel Borges 11 -
0
votes1
answer195
viewsSentence while - not true... understanding logic
I’m having a lot of trouble understanding why the program stops when I type n=0. when type 0 the finished turns to True, and the while logic is just this, no? I’ve run the program and it’s correct,…
-
0
votes0
answers1022
viewsHow to change bar colors individually in matplotlib?
Hello! Can anyone explain to me how the principle works to change the colors of the bars individually? All I can do is change the color of the whole chart. For example: From Blue to Black / From…
-
0
votes0
answers147
viewsVSCODE on Ubuntu with Unknown word error
I am using VSCODE with Ubuntu and after copying a program (python) that is working in VSCODE environment with Windows it presents in several lines a few words with error "unknown word" this happens…
-
0
votes1
answer126
viewsHow to create a CNN model correctly in Keras?
I want to make a convolutional neural network model using Keras. Input is a set of images of size 360,640,3 and the exit shall be 720,1280,3. So I made the following model : w,h,c=x_train[0].shape…
-
0
votes5
answers821
viewsAvoid blank input data
I have an empty list that will be fed by inputs. In case, how do I go through the list and check if any data has been entered blank and treat it to fill in again? Example: lista = [] variavel_1 =…
-
0
votes1
answer98
viewsInstagram Scrapping
This is my first python program and basically my first one with programming (since html does not fit kkk). I had the idea to map the information of an entire city as profiles of people, of…
-
0
votes1
answer1185
viewsHow to request on a server using digital certificate for Python/Django authentication
I am trying to use the api of a system that is available in a web link, however the server of the api requires as authentication a certificate of type pem, I already possess this certificate,…
-
0
votes4
answers2542
viewsAccess list element within Python list
I have two lists within a list and each index of the list contains an ordered pair, in this way: [[2, 5], [3, 6], ..., [x, f(x)]]. I want to know how to access a specific item of one of the lists,…
-
0
votes1
answer231
viewsI can only open png images with Tkinter
I’m trying to open up images jpeg with Tkinter using the PhotoImage, but I can’t. The program and image are in the same folder, but still it gives error: couldn’t open "image.jpeg": no such file or…
-
0
votes2
answers169
viewsCode improvement
Hello. I have this code: import os from selenium import webdriver import time def visita(link): try: options = webdriver.ChromeOptions() options.add_argument('--headless') driver =…
-
0
votes1
answer515
viewsMysql and python error when entering data
I have the following code: #encoding: utf-8 from django.utils.encoding import smart_str import mysql.connector mydb = mysql.connector.connect( host="localhost", user="[--CENSURADO--]",…
-
0
votes1
answer103
viewsVariable declaration in Python
I have a question regarding the creation of variables in Python using Pycharm, always when I declare a variable a green underscore is displayed and the message that appears is: Type: In Word…
-
0
votes2
answers848
viewsProblem with balance of parentheses, in Python
Galera to with the following code: exp = str(input('Digite a expressão: ')) pilha = [] for simb in exp: if simb == '(': pilha.append('(') elif simb == ')': if len(pilha) > 0: pilha.pop() else: if…
-
0
votes1
answer1219
viewsPython Pandas insert records into a column according to the data present in a Dataframe
Good evening, I have an Excel spreadsheet that has a column called Cod and within that column are the valores: 01, 02, 03 I need to create another column in this table that does the following:…
-
0
votes1
answer226
viewsAverage frequency using dictionary
I want to check the frequency of words returned in a book (format .txt) and divide this frequency by the number of chapters found, thus obtaining the average word appearance per chapter. The point…
-
0
votes1
answer361
viewsPython error locale
locale.setlocale(locale.LC_ALL, "Portuguese_Brazil.1252") data = pd.read_excel('C:/Users/t714591/Videos/bancos/base.xlsx') data["Valor"] = locale.currency(data["Valor"], grouping=True, symbol=None)…
-
0
votes1
answer105
viewsWhat are the differences between these two ways to save form information?
I am learning how to use Jango forms and I have been presented with two ways to save information from a form in a database. I tested both and both work with validations, but did not understand what…
-
0
votes1
answer321
viewsTkinter Python Toplevel
I want to make the btnteste button modify the text in the label(root), I am unable to do from tkinter import * root = Tk() root.geometry("800x600+600+200") root.resizable(False, False)…
-
0
votes1
answer265
viewsUsing groupby in a dataframe
I have a dataframe with 60 columns, but for the case need only 3 ID DT_DATE NR_PRICE 0 22828949 2019-02-26 453.00 1 22828949 2019-02-22 453.00 2 22828949 2019-02-18 453.00 3 22828949 2019-02-05…
-
0
votes1
answer486
viewsHow to open a . sql file in pandas?
I intend to make a dataframe of a database that I imported from pgadmin4 as a 'vialactea.sql' file when I try to execute the pandas command in jupyter only from the error message. The bank is saved…
-
0
votes2
answers162
viewsJoin of lists in Python
How to join two lists in Python to form a single list ? For example, I have this list [[1, 0, 0, 0], [1, 1, 1, 0], [1, 0, 0, 0]] and I want to join her with [[1, 0, 1, 0], [1, 0, 1, 1]]. I want the…
-
0
votes1
answer179
viewsExport Postgre SQL table to text (csv) via psycopg2
I am trying to export a table from the Postgres database to a txt (csv) file via Python, via psycopg2. However, I am encountering an error. The code is as follows (I switched login information to…
-
0
votes2
answers542
viewsDjango - Questions with Foreignkey
I’m trying to make a form in Django, in which I will save the versions of the projects. Exemplo: Empresa x Projeto 1 Versão 1 Versão 2 Projeto 2 Versão 1 Empresa Y Projeto 1a Versão 1 ... It happens…
-
0
votes1
answer179
viewsRead Numpy files in Jupyter Lab
Good afternoon, I am currently developing an Artificial Intelligence project. In the current phase of my project, I have my neural networks implemented and I am in the phase of training the neural…
-
0
votes0
answers1925
viewsVscode does not recognize external modules in Python
I am using vscode to learn python because I found it more pleasant, but when I try to import libraries from pypi.org after downloading them VSCODE points out that there is no module with that name…
-
0
votes1
answer61
viewsInstantiating multiple objects
I’m trying to instantiate an object multiple times, from a single class, defined below: class lancamento(): def __init__ (self,date,description,value): self.date=date self.description=description…
-
0
votes1
answer1290
viewsTXT OF BANK EXTRACT (RELEASES)
You guys, good morning. I have the following problem. I have some txt-like bank statements files that I need to play on for a dataframe, until they have a sort of standard layout. I need to take…
-
0
votes3
answers46
viewsHow to modify a repeat
Follows the code: numero = int(input('Digite um número:')) msg1 = ('Errado') msg2 = ('Tá osso em') while numero != 0: print(msg1) numero = int(input('Digite um número:')) print('Certo') How do I…
pythonasked 4 years, 8 months ago Glebson Santos 39 -
0
votes1
answer1245
viewsHow to create a CSV file via Python by keeping the decimal separator in the same place?
I have a Python script that makes a request via API and saves the data in a CSV file. The data is stored in different lists in Python and should be saved in different columns in the CSV file. The…