Posts by Reinaldo Chaves • 333 points
28 posts
-
0
votes1
answer123
viewsQ: How to use PROCV to search for code in two spreadsheets?
In Excel 365, version 1907, and Windows 10, I have an XLSX file with two almost equal sheets - Sheet 1 and Sheet 2. Contents of the Spreadsheet1: Contents of the Spreadsheet2: I want to check in…
-
1
votes2
answers816
viewsQ: In requests, how to correctly read the ISO-8859-1 encoding?
In Python3, with beautifulsoup4 and requests, I want to extract some information from a site that has encoding 'ISO-8859-1'. I tried this strategy to show correctly the text: import requests from…
-
0
votes1
answer240
viewsQ: How to correctly read a multi-level JSON?
In Python3 this code reads the Senate API to create a dataframe of one-year propositions import requests import pandas as pd headers = {"Accept" : "application/json"} proposals = [] url =…
-
0
votes1
answer139
viewsQ: How to read a JSON with missing fields to fill in a dictionary?
In Python 3 this code reads the Federal Senate API, the proposition data: import requests import pandas as pd headers = {"Accept" : "application/json"} url =…
-
0
votes1
answer1013
viewsQ: How to fit the geckodriver for use of Selenium?
In Python 3 and Ubuntu, I want to run a test with Selenium: from selenium import webdriver from selenium.webdriver.firefox.firefox_binary import FirefoxBinary from time import sleep binary =…
-
0
votes1
answer985
viewsQ: How to create dataframe in pandas from series with dictionaries?
In Python3 and pandas I have a series with lists. In each row of the series there is a list, with dictionaries inside. It was obtained from a file: import pandas as pd geral =…
-
1
votes1
answer172
viewsQ: On big scrapings how to avoid Connectionerror?
In Python 3, I have a program to make web-scraping tables on websites. There are 5,299 pages, on each page there is a table With XHR I found the generated JSON on each page. But there is always a…
-
0
votes1
answer869
viewsQ: In pandas and unidecode, how to avoid warning messages - copy of a Slice from a Dataframe?
In Python3 and pandas I am reading CSV files to create dataframes. In some columns I need to remove the accent (English). I do it with unity But in some files appears a warning message import pandas…
-
0
votes1
answer3305
viewsQ: In pandas, how to merge two dataframes, but only one section of two columns?
In Python 3 and pandas I have two dataframes eleitos_d_doadores_d.info() <class 'pandas.core.frame.DataFrame'> Int64Index: 16090 entries, 16 to 26412 Data columns (total 23 columns): uf_x…
-
1
votes1
answer2667
viewsQ: How to avoid Max retries exceeded error in scraping in Python?
In Python 3 I made a program to scrape table lines from a public website with several pages (97893). And I create a list with the rows of each column and put a sleep to try to prevent scraping from…
-
1
votes0
answers893
viewsQ: How to correctly read a JSON API and create list?
In Python3 I made a program to read an API (from the House of Representatives) and get the data in JSON import requests import pandas as pd url =…
-
0
votes1
answer108
viewsQ: How to select codes with different sizes in pandas?
In Python 3, with pandas, I have this dataframe with several codes in the columns "Cpf_cnpj_donor" and "Cpf_cnpj_donor" cand_doacoes = pd.read_csv("doacoes_csv.csv",sep=';',encoding = 'latin_1',…
-
2
votes2
answers4670
viewsQ: How to use Selenium Webdriver findElement(By.xpath())?
Hello, please, I am trying to get information on a public website: name of a vote, date and table with voting list This site:…
-
2
votes2
answers1120
viewsQ: How to keep zero left on import in Python?
Hello I have several TXT files with CPF numbers. CPF has 11 numbers, so you can have zeros left to complete this size I opened these files in Excel and gathered them in one. In the CPF column,…
-
1
votes1
answer2411
viewsA: How to round value created on pandas?
ANSWER THAT WORKED, OF LUIZ VIEIRA - already when reading the CSV you indicate that the decimal is with ",": cand_doacoes = pd.read_csv("doacoes_csv.csv",sep=';',encoding = 'latin_1', decimal = ",")…
-
1
votes1
answer2411
viewsQ: How to round value created on pandas?
Hello Please, in pandas Python 3 I am creating this dataframe with the sum of another dataset: total = cand_doacoes.groupby(['CPF_candidato', 'Nome_candidato', 'Cargo']).Valor.sum().reset_index()…
-
1
votes2
answers2142
viewsQ: Create list with column contents
Hello Please have a pandas.core.frame.Dataframe with these columns, in Python3: Estado 150 non-null object Cargo 150 non-null object Nome_candidato 150 non-null object CPF 150 non-null int64…
pythonasked Reinaldo Chaves 333 -
1
votes3
answers568
viewsQ: Memoryerror on the pandas
Hello I am using the pandas merge command in python3: ibama_doadores_orig = pd.merge(eleitos_d_s_doadores, ibama, left_on='CPF_CNPJ_doador_originario_limpo', right_on='CPF_CNPJ_limpo') But a message…
-
2
votes3
answers7021
viewsQ: How to change the type of a column in Pandas?
I want to change the type of a column of a CSV file. I used this command: cand_doacoes['CPF_CNPJ_doador'] = cand_doacoes.CPF_CNPJ_doador.astype(int64) But the error appears: NameError Traceback…
-
2
votes2
answers233
viewsQ: How to extract all td names in order?
I need to extract all the names of people on this site: Camara.gov.br I wrote this code in Python3: from urllib.request import urlopen from bs4 import BeautifulSoup import urllib.request,…
-
0
votes1
answer1202
viewsQ: Is there a size limit on the writerow of csv?
I will create a CSV of 1,341 lines (with header). In Python 3 I used csv commands, but the file created has 1,282 lines The line data is extracted from 1,340 Pdfs, from the metadata. I created a…
-
0
votes1
answer65
viewsQ: How to work with multiple codec’s in pdf?
I have a set of over 1,000 Pdfs that I need to extract the metadata. The problem is that Pdfs have different codecs. The first example worked, I used utf8. The second example gave error. It is…
-
0
votes1
answer128
viewsQ: How to isolate metadata with pdfminer?
I wrote this code in Python 3 to read the metadata of a PDF: >>> from pdfminer.pdfparser import PDFParser >>> from pdfminer.pdfdocument import PDFDocument >>> fp =…
-
0
votes0
answers2315
viewsQ: How to download a file with Python?
This site has several links that open Pdfs, in the locations of "Entire content": http://www.camara.gov.br/proposicoesWeb/prop_emendas?idProposicao=2122076&subst=0 In Python 3 I wrote this code…
-
-1
votes3
answers773
viewsQ: Pandas does not find file
I am using pandas in Python to read a CSV file that is on my computer, however appears an error message, it seems that it does not find the file: import pandas as pd reclamacoes =…
-
2
votes1
answer3370
viewsQ: Object is not subscriptable error
Hello Please, I want to record a csv file from a list, but this error appears: --------------------------------------------------------------------------- TypeError Traceback (most recent call last)…
pythonasked Reinaldo Chaves 333 -
1
votes1
answer275
viewsQ: Scrape list on website with beautifulsoup
I need to scrape in Python a list on a website. Only the first list My code is like this: import requests from bs4 import BeautifulSoup page =…
pythonasked Reinaldo Chaves 333 -
1
votes1
answer184
viewsQ: Creation of empty csv
hello on the python code below, I want to create a csv with the sum of inhabitants in each state but it creates an empty csv file please, someone has idea of the problem? the original csv file in…