Most voted "pandas" questions
Pandas is an open source library, which provides high performance data structures and data analysis tools for the Python programming language.
Learn more…646 questions
Sort by count of
-
1
votes1
answer79
viewsPython - Data Analysis - Error reading file in xlsx format
Good afternoon, I am trying to read an xlsx file in python via pandas, but it returns errors; as if the file did not exist (however it is in the same folder as the python script). I tried to pass…
-
1
votes2
answers351
viewsCompare Dataframes and show different information between them
I have 2 dataframes, the df_a and df_b. How do I compare them and show the information that is not contained in the dataframe df_a? I tried to perform the Uplicates drop method, however, the output…
-
1
votes1
answer52
viewsHow to split columns/data with a specific limit?
Hello, my friends! Currently I do a scientific research in the field of AI, Machine Learning - Classification, using the Python language. In view of this, I have some data to develop an algorithm,…
-
1
votes1
answer282
viewsGenerate XML file of more than 1 Mi of records with Xml.etree.elementtree in python
Please, how can I generate an XML file, with Xml.etree.elementtree in python, but in such a way that it creates the file of 5 thousand in 5 thousand resgitros, without the need to wait to load the…
-
1
votes0
answers24
viewsConvert CSV to XLSX with Python Azure Function App
I am trying to create a Functionapp on Azure to convert a csv file to xlsx. My original script that works on windows local is this: import pandas as pd read_file = pd.read_csv…
-
1
votes1
answer88
viewstransform data from a Dataframe column into a single string
I have a Dataframe with a column that has different texts in each row and I intend to join all the lines in a single string, it is possible? the idea is to turn all the sentences in the column into…
-
1
votes1
answer51
viewsPython Dataframe dynamically
I have data with the following columns: "Date","Codproduct","Sale","Quantity" I need to create several data frames in python, filtering product and selecting the other columns and always saved with…
-
1
votes1
answer1046
viewsHow to filter lines that have a certain string?
I know that the command dados[dados.Value == 'disease'] only the lines where the value of the column "Value" is exactly equal to the string "disease", but I need to select all the rows in the column…
-
1
votes1
answer51
viewsHow to transform the subtraction field between dates in python into int?
Hello I have the following code that turns a "Brazilian" date into a standard date: df2['Start_Date'] = df2['Start_Date'].apply(lambda x: datetime.strptime(x, '%d/%m/%Y')) df2['End_Date'] =…
-
1
votes1
answer303
viewsUsing resample on pandas with intermittent date variable
I have a database in which one column is the year and the other columns are the total of formal workers in a city (each column a city). My goal is simply to aggregate my annual data to triennials.…
-
1
votes2
answers93
viewsHow to create multiple columns using the values of one in pandas?
I have the following code: df = pd.DataFrame(repeat_R) print(df) The dataframe I have is like this: 0 0 0.583822 1 0.582975 2 0.541191 3 0.526122 4 0.547239 5 0.555875 6 0.556838 7 0.524316 8…
-
1
votes1
answer48
viewsHow to Capture Data with Pandas?
I work with a database that uses frequency, and I want to analyze the frequency data and transform it into several lines. Follow image example: I want to make line 6, for example, become 6 equal…
-
1
votes1
answer67
viewsIdentify matching in dataframes
Dataframe D1. Ano/Mês Referência Ano/Mês Competência UF Código Município SIAFI Nome Município SIAFI NIS Beneficiário Nome Beneficiário Valor Benefício 0 201301 201202 AL 2785 MACEIO 16035155015…
-
1
votes0
answers51
viewsProblem with the xticks - matplotlib
I’m a beginner in the Science data area and I’m developing my solution to the Kaggle Titanic problem (https://www.kaggle.com/c/titanic). At the moment I am creating a visualization to verify the…
-
1
votes1
answer158
viewsWhy use double clasps in Pandas?
Given the following Dataframes: df = pd.DataFrame([[1, 2, 1], [4, 5, 2], [1, 2 , 3]], columns=['coluna1', 'coluna2','id']) df2 = pd.DataFrame([[1, 7, 1], [4, 'a', 2], [1, 'abc', 3]],…
-
1
votes1
answer33
viewsClick on a button inside the power bi with python
My dear, I need my robot to click the button inside the power bi to upgrade, for it to upgrade alone, just missing this part so it gets 100% import os import pyautogui import time…
-
1
votes1
answer74
viewsSuggested improvement of code, for opening of several csv files in different directories
Good evening friends, a friend passed me a code that he was developing so that I could study, however I would like to see a better alternative to the opening of various files . csv, only they’re in…
-
1
votes3
answers348
viewsArithmetic operations where some Dataframe data is not int in Python (pandas)
I am working with some data from IBGE and I meet with two spreadsheets that I need to take their percentage. The formula for this is very simple, ie: percentage = (dividend / divisor) * 100…
-
1
votes1
answer21
viewsPython Pandas - Conditional partial dataframe string
I have the following situation: I own a dataframe: data = {"Id": ["01", "02", "03", "04",'05'],"Fruta": ['Maçã','Abacaxi','Banana','Laranja','Morango']} base_dados = pd.DataFrame(data)…
-
1
votes1
answer1271
viewsHow to make a dynamic table in a Pandas dataframe?
Good afternoon. I’m migrating some activities from excel to python (an environment I’m still a layman), and came across a problem in making a dynamic table. I tried using pivot_table but could not…
-
1
votes2
answers2626
viewsHow to make a "procv" in Python using the Pandas library
good afternoon! I got csv down: Nome Vendas Produto Data Carlos 83,40 cod2 15/04/2020 Andre 70,50 cod5 10/04/2020 Cristina 100 cod7 25/04/2020 Carlos 20,80 cod1 03/04/2020 Gisele 10,50 cod9…
-
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
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
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
answer24
viewsHow to use 2 lists to change Mysql via Python 3.x, in this case
Good guys, all right? I am creating a script in Py by COLAB itself because I need to change the weight of various products in Woocommerce, I capture the ID of a product group based on size 300ml,…
-
1
votes1
answer37
viewsHow to use a Tkinter Checkbutton to interact with a Pandas dataframe
I’m trying to make an interaction with a dataframe in Pandas, I’ve tried several solution options I found here in stackoverflow, but I haven’t been successful yet. If anyone can help me, I’d be very…
-
1
votes2
answers80
viewsHow to clear lines on pandas using a list as a filter?
Given the df as indicated below (could be a greater good), I would like to delete in df the data of the lines according to the list 'listFilter'. nome =…
-
1
votes2
answers136
viewsHow to improve runtime
I have a csv with data from some matriculations I’m doing a study, I generated an id for each matriculation, and wanted to check if it repeats in the same year. I have the following code: # retorna…
-
1
votes1
answer76
viewsHow to generate an ID to identify a student in a database with enrollments of several years?
I have the following basis of dice that contains enrollments of an institution that is developing a research, in the future to make a mapping of students I need an id that identifies each student,…
-
1
votes1
answer1220
viewsI need to select the last Dataframe value to calculate the value of the next row in the same column
I need to select the last value of the column "Season Minimum" to calculate the value of "Mint", name I gave the variable of the same column, currently my line of codes is like this: import numpy as…
-
1
votes1
answer120
viewsHow to verify null value in rows in a dataframe column?
I’m looking to replace the null values with the value of the year. Given the following dataframe : year value 2000 1 NaN 2 NaN 3 NaN 4 NaN 5 NaN 6 2001 1 NaN 2 NaN 3 NaN 4 NaN 5 NaN 6 ... 2020 1 NaN…
-
1
votes1
answer56
viewsCollect fraction of a text in a Pandas column [Python]
Good afternoon! I’m having a hard time separating the name of the countries into a string column (text), where I don’t have a common separator, I’m not even sure where to start. Basically, my idea…
-
1
votes2
answers82
viewsGroup closer values in Postgresql
Good morning, you guys. I have a question regarding a grouping of data in postgresql and I would like to know if you can help me. I have a database containing a table with entry times in an…
-
1
votes1
answer62
viewsHow to get the total of combinations between two datasets and the sum of their attributes?
I have two datasets (brake and gear). Both the brake date set and the Ambios data set have attributes (Force, Aero, Grip and Rely). I would like to get the total of combinations between these…
-
1
votes1
answer342
viewsOutlier Detection with python
Hello. I am currently learning Data Science, currently I am at the beginning of Machine Learning, and during my studies I realized that the data has to be organized and within "line, "very…
-
1
votes0
answers52
viewsHelp with Precision in Machine Learning Sorting Algorithms
I am following a class where the teacher creates a code that will evaluate 7 different algorithms classificatory of Machine Learning and I tried to do in a more automated way so that this data…
-
1
votes0
answers67
viewsDoubt regarding Excel manipulation through pandas library in Pycharm
I have a question regarding the manipulation of Excel through the pandas library. First I import the pandas library, then I assign to a variable the path that is the spreadsheet. import pandas as pd…
-
1
votes1
answer32
viewsCreating a new column using for
Hello people I am using this database 'https://cdn.tse.jus.br/statica/sead/odsele/votaca_partido_munzona/votacao_partido_munzona_2020.zip' to work. I would like to create a new column in the…
-
1
votes1
answer248
viewsUsing regex to convert latitude and longitude coordinates of degrees/minutes/direction to decimal in python
I am trying to convert latitude and longitude data into python which are in the following format: Latitude Longitude 27º59' N 86º55'E This data was extracted from the following web page and…
-
1
votes1
answer133
viewsAbstract class 'Excelwriter' with Abstract methods instantiatedpylint(Abstract-class-instantiated)
I’m trying to save some Dataframes in an excel file but the same is giving error, I saw some tutorials and even leaving identical still gives error. writer = pd.ExcelWriter('pandas_simple.xlsx',…
-
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
answers92
viewsApplying apply function on a pandas dataframe
I have a code (CODIGO01) that calculates the moving averages (21 periods) of a particular (individual) stock exchange share (IBOV - B3). Then I created a loop for where it determines q an asset this…
-
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
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
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
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
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
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
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…