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
answer138
viewsPandas: Acceptance and rejection percentage
I have a dataset that contains some columns that inform me: user, situacao_requisicao, city. I would like to generate a csv that informs me the amount of requisicoes of each city, how many were…
-
-1
votes1
answer151
viewsHow to save a CSV in memory using Python?
Hello! I need to read a big CSV, break it into 1000-line Csvs, store them in memory and then reset a zip with these smaller files. This is the code so far: import pandas as pd from io import…
-
-1
votes2
answers573
viewsPython / Pandas - error reading Arq. csv ( path)
I’m using Google Colaboratory and trying to read a CSV file, separated by ";" and is giving the following error. I think it has to do with the path. What I’m doing wrong? import pandas as pd…
-
-1
votes1
answer30
viewsDataframe input
Good morning guys, I’m creating a expense control to be used as a data science study. However, I would like to make the user able to enter the values and feed this dataframe. The expression I have…
-
-1
votes1
answer31
viewsHow to compare if the value of a dataframe column is in an array if you are creating a new column with that value?
lista = array(['NF', 'BT', 'C', 'N', 'I', 'IP', 'Aa', 'Sa', 'Gl', 'Et', 'To', 'Hr', 'Cr', 'Ro', 'X', 'Oa', 'Ml', 'Me'], dtype=object) "DATAFRAME" x_1 x_2 0 NF 0 1 A 0 2 B 0 3 KK 0 4 Gl 0 5 Oa 0 The…
-
-1
votes1
answer70
viewsHow to read a csv file by pandas without erasing the first number?
Hello, I have a.csv file and I want to read with the pandas library in Python. When I run the command it takes the first 0 from the sequence of numbers. Can someone help me with this? I want him to…
-
-1
votes2
answers354
viewsImprove python apply performance with lambda
Hello. I am developing a code in python but it is taking time to run, I wonder if there is any other more effective method. Below follows the def that I use def…
-
-1
votes1
answer99
viewsPandas convert epoch str to datetime
Good afternoon, everyone. I need help converting types in pandas. Follow the information: I have CSV containing the Intel, a Bulletin field, ctime, mtime and the name of the files respectively,…
-
-1
votes1
answer42
viewsAdd data within a dataframe based on a condition for two columns
I have a DF with four columns. I need to add the values of column 3 when the values of column 1 and 2 are duplicated and discard duplicates. Ex: df = pd.DataFrame({"A": [1,1,1,1,2,2], "B":…
-
-1
votes1
answer25
viewsHow to remove duplicate names in rows from a python dataframe?
Hello, everybody. I have the following dataframe: df = pd.DataFrame({ 'Codigo': [1, 2, 3, 4], 'Nomes': ['Alan Silva, Alan Silva', 'Carlos Santos, Carlos Santos', 'Joao Pedro', ' João Pedro'], }) df…
-
-1
votes1
answer24
viewsRemoving non-numerical value from a dataframe
My intention is to remove the values that appear with '...' as shown above and replace with an empty field. The code I’m using to try to remove is this: df['Energy Supply'].str.replace('[.]*', '')…
-
-1
votes2
answers106
viewsSaving csv file using python
I have the following problem: I have a csv file with multiple numbers. I read this file, pass a header and make the separation The problem happens when I try to save this data in a new csv file.…
-
-1
votes1
answer450
viewsTransform dataframe column into INT - Python 3
Hello I have this Dataframe, generated from a file (.txt): NUMERO_PROCESSO ANO_PROCESSO TRIBUNAL 0 0010402 2018 18 1 0010758 2014 01 2 0001622 2012 08 3 0020287 2019 04 4 1001446 2018 02 5 0000795…
-
-1
votes2
answers407
viewsChart with Seaborn with one of the axes being the index
I have a dataframe, it has a standard index, but replace this standard index by the name of the Brazilian states and now I would like to plot a Plot bar vertical, using the Y axis with the name of…
-
-1
votes2
answers34
viewsHow to access an attribute or method from a variable?
I’m getting this mistake: Erro: " 'Series' object has no attribute 'medida' " Is there any way to put a variable in place of the method and Dataframe recognizes the attribute? Below is the code as I…
-
-1
votes2
answers107
viewspython cleaning raw data manually
import pandas as pd data_r = open('rosalind_gc.txt', 'r') data_r1 = data_r.readlines() data_r2 = [] data_r3 = [] #tirar os \n do texto for i in data_r1: data_r2.append(i.rstrip()) data_index = []…
-
-1
votes2
answers2310
viewsSplit a column into two from a parameter - Python
I researched a solution but I can’t locate facing a data frame, just input lines for example. I HAVE A DATAFRAME WITH THE FOLLOWING FIELDS AND LINES: data = {'País': ['Bélgica', 'Índia', 'Brasil'],…
-
-1
votes1
answer385
viewsData Reader in Python
Hello to the python community. I am a student of economics and beginner in python. I’m developing a code to pursue return on stock purchase, buy and hold. However, I have a problem with the search…
-
-1
votes0
answers13
viewsEXTRACT LATEST EXCEL FILE INSIDE A PYTHON FOLDER
I would like to know how to tell python(pandas) that I only want to import the latest file you have in a certain folder. Every day the folder is updated with a new file and every day the program…
-
-1
votes0
answers22
viewsHow do I invert a dataframe?
How do I display this df in reverse order ? I did the inversion by the index, but only the index reversed, the data of the dates without inversion remained in the same position. Basically I want to…
-
-1
votes1
answer20
viewsIMPORT SPECIFIC EVENT - PANDAS
I have a script where I loop for and run about 330 files, in order to consolidate and apply a filter at the end of the process. As a beginner, I made a few attempts but without success. I want to…
-
-1
votes1
answer89
viewsHow to delete aggregated columns in a Dataframe Pandas obtained through the 'pivot_table'?
Hello, I managed a Dataframe in Pandas with the following command: df_projects7 = pd.pivot_table(df_projects8, index=['id_prj', 'Nome do Projeto', 'criado_em'], values=['Percent_executado',…
-
-1
votes1
answer29
viewsPython: loop to "clip" (winsorizing) numerical data on a dataframe, assigning the result to a dictionary
What’s wrong with this code? #calculando retornos diários máximos e mínimos: max_std = 3 max = {} min = {} retornos_stds = retornos_dia.std() retornos_med = retornos_dia.mean() for acao in acoes:…
pandasasked 4 years, 7 months ago Lucas Secundo 1 -
-1
votes1
answer39
viewspython timestamp argument error
I’m converting a set of dates and trying to plot a chart with the converted values but I’m having the error following, someone knows what can be? dates = data['data'] date_format =…
-
-1
votes1
answer39
viewsI cannot understand why this value is Nan in the column "[lethalityRegionalSaude]"
#letalidade por estado letalidadeRegionalSaude = [] for i in range(len(regional_saude)): letalidadeRegionalSaude.append(regional_saude.obitosNovos[i] * 100 /…
-
-1
votes2
answers54
viewsSeparate extension name - in Python
I have a column in the spreadsheet in Excel with the following column: Atendido por Ismael (100) JEFFERSON LUIZ ESTEVAO DE MOURA (111) Felipe Braga Regis Souza (222) I have to take just the name and…
-
-1
votes1
answer90
viewsProblems with CSV file (python)
I am using a basic code of a channel, but I would like to remove the data quarterly, so I changed the link of the original code only, but when trying to run the program I have a problem, I am…
-
-1
votes1
answer258
viewsHow to convert multiple columns from Object to Numeric in pandas?
good afternoon. I have a problem in an Aceleradev activity in Data Science, I would like a help. When I call the function . info(), it displays the values below: countries.info() <class…
-
-1
votes1
answer1130
viewsLimit to Python 3 decimals
I made a script in python and need help. As you can see, a spreadsheet in excel is opened, treats the data and returns to another spreadsheet. When opening the new spreadsheet, the numbers get huge…
-
-1
votes1
answer49
views -
-1
votes1
answer463
viewsGoogle Gspread colab and pandas
I started using google colab to do some analysis of the company and it gives the option to instead of reading the csv file, already automatically read the existing file in the google sheets in the…
-
-1
votes1
answer118
viewsWeb Scraping with Pandas - How to treat values that are null in the collection and how to concatenate two columns in the final result?
I’m making a Web Scrap using Python and Pandas, on Windows. I am collecting the data from the page, generating a Dataframe in Pandas and then exporting to an Excel spreadsheet. I’m not using any…
-
-1
votes1
answer26
viewsWrong value when creating dataframe
I’m looking to create a dataframe with 2 columns - meses and valor. Only the values of the value column are coming wrong. Showing step by step what I am doing: Sum the total of each month of other…
-
-1
votes1
answer56
viewsUse drop or iloc in Machine Learning modeling in Pandas?
I’m learning Machine Learning for Data Science through Pandas. I made a few algorithms and performed the division of my predictive variables and class as follows: dados = pd.read_csv(...) (...)…
-
-1
votes2
answers150
viewsCross-reference two different dataframes with different line numbers
I have the following dataset df.head() In the column Education degree, I have the values of the indices of each education degree, shown in the table below: Grau_Instr_Bibl = {'Categoria':…
-
-1
votes1
answer47
viewsIn Python, check if the contents of one column are present in another column?
I’m at Jupyter Notebook working with Python. My current dataframe is in the following format - data.Columns['name', 'filename', 'text']. All columns are string type, wish, take the 'name' column and…
-
-1
votes1
answer47
viewsFetch value of a condition on lines and separate into a new dataset
I have the following dataset I’m trying to create a dataset based on the dataset above. I am trying to search row by row values that are not Nan, export to a new dataset this value linked to column…
-
-1
votes1
answer74
viewsHow to create a Dataframe in Pandas based on two Features and more the count of one of them?
Good afternoon to everyone, I’m conducting a data analysis project and I’m having difficulty at a specific point. To facilitate understanding, I have a DF with [1000000+ rows x 29 columns]. In this…
-
-1
votes1
answer41
viewsSum pandas columns by row and selecting comparative by Qgrid row
import pandas as pd import seaborn as srn import statistics as sts dataset = pd.read_excel('/content/drive/MyDrive/Data science /BRA 2020.xlsx') dataset.head() dataset = dataset.drop ('League', axis…
-
-1
votes1
answer57
viewsCreate column based on another dataframe
Good night! I have two dataframes ex8_alunos and ex8_cursos ex8_alunos ex8_cursos I would like to create a column on ex8_alunos calling for CO_UF To power this column I would need to cross-reference…
-
-1
votes1
answer17
viewsROOT-Cern import inside a virtual env and inside lxplus
I need to use Condorht (CERN software) for my analysis, but the python macro I want it to work on has some libraries that cannot be imported into lxplus(Ern environment), so I created a virtual…
-
-1
votes1
answer49
viewsCHANGING VALUES ON A DATFRAME
Good afternoon. I have a Dataframe with the following head(): Note that in the bmi column there are Nan values, more precisely, there are 201 lines. I want to change this value based on the age…
-
-1
votes1
answer130
viewsHow to store print values in a variable in Python?
I imported data from a table in Google Sheets using Pandas and created a data frame. I renamed your columns and made a for loop to filter between one of these columns, the values below 20, however,…
-
-1
votes1
answer53
viewsPrint of the smallest number of a pandas table
Hello, I have a CSV file with 1000 lines and 10 columns, one of the columns shows the age of the people, the minimum male age is 0 and the maximum is 96, but when giving the print the result comes…
-
-1
votes1
answer73
viewsHow can I check if a column of a dataframe is contained in a column of another dataframe?
Hello, I have the following question: I have two dataframes and I want to check if the values of one column contain in another column of another dataframe that does not have the same name nor the…
-
-1
votes1
answer32
viewsrename rows of a dataframe
I have a dataframe: codcliente contrato 7 1180000007004 7 1180000007003 7 1090000007038 2 1090000007035 2 1090000007029 ... ... 3 2023885638001 3 1073885769001 3 1093885790001 3 1183885847001 3…
-
-1
votes3
answers34
viewsDoubt about converting str to int with py/pandas ((dataset))
I have a column of notes in string format. They come as follows: 432432.0 Always comes with . 0 then I wanted to go straight to int and not to float As ta in this format I saw that I should first…
-
-1
votes1
answer36
viewsPython: consolidate duplicate lines by adding values
I have a spreadsheet in excel format (.xlsx) with the following columns: "matricula", "name", "value", as shown below. I would like to delete the repeated data by adding up the values. The final…
-
-1
votes1
answer37
viewsSend Email formatted Python
Good afternoon, I’m in need of some help regarding python and pandas. I need to generate a weekly ranking from some reports I extract from the system, the data I’m able to query but I need me to…
-
-1
votes2
answers41
viewsHow to map values with Dataframe pandas
I am trying to create a new data column in pandas format based on two other dataframes. This first dataset is where I get the values: GenPart_pdgID = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 0 -4 4 23 23 23…