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
answer25
viewsHow to create a directory structure in memory with Python?
Hello. I have the following scenario: I am reading a dataframe, which has a column with Xmls. I am writing these Xmls to files. xml separately, to later save them in a certain folder structure and…
-
-1
votes0
answers21
viewsPython if function
Hello, In a database with vaccine information per day, I want to compare whether the sum of each laboratory (Sinovac, Pfizer and Astrazeneca) is different from the reported total. If it is, I want…
-
-1
votes0
answers8
viewsPandas read_html is joining the information by adding the information from the bottom line to the line above in merged lines
I’m new to python and maybe it’s obvious the answer, but come on: I need to work with a file downloaded from a website that comes in xls format but is originated in html. So I need to use read_html…
-
-2
votes1
answer35
viewsGraphic description in overlapping pizza
How to solve this? Captions of the pie chart overlapping with others.…
-
-2
votes1
answer55
viewsRepeat code for the same product group
I have a spreadsheet with thousands of products according to the example below, where the code is only in the type of service (left column), and I want it to be in all products of the same type…
-
-2
votes1
answer1116
viewsWorking with time in pandas and python
I have a dataFrame in which two columns are of the type datetime.time and I need to subtract one from the other and get the value in minutes. To turn into datetime.time did so:…
-
-2
votes1
answer76
viewsSeparate columns from a dataset
I need to separate in a list the column types of a dataset in numerical and non-numerical. For example: def identifica_tipos(df): col_numerica = [] for col in df.columns: if col.isnumeric:…
-
-2
votes1
answer332
viewsHow to format sum() output in Python dataframe
I would like to format the result of sum(). When I use the following command: # Valor concedido de aposentadoria por ano df.groupby('Ano')['Vlr Benefícios Concedidos (R$)'].sum() It returns me the…
-
-2
votes1
answer34
viewsRemoving higher value from line with for
Good afternoon, I’m trying to extract the largest whole value from every line of my dataframe. I created the following code for this: for i in df.index: df["maxx"] = df.loc[i].max() df["minn"] =…
-
-2
votes1
answer53
viewsimport PYTHON / PANDAS
I need to import a txt and take only a few characters as below: Text: 000524WEQWE256243443507AFDAF1698100005891710232323062 Code: a = (0, 6) = 000524 b = (6, 5) = WEQWE…
-
-2
votes1
answer127
viewshow to deal with Nan in Dataframe created with list comprehension (Python)
How can I take these NaN and leave the titles of the films, by any of the construction methods? import pandas as pd rating_data = pd.read_csv('ml-25m/ratings.csv') movies_data =…
-
-2
votes3
answers2351
viewsImport csv with pandas. Column values with semicolon. What to do?
I’m importing CSV files with pandas to do a data wipe. And I’m finding a problem. Some values have ';' . For example: df[0][1] = "STREET A ; " I import csv through: df = pd.read_csv('GUAXUPE.csv',…
-
-2
votes1
answer234
viewsHow does "parse" work for handling dates in Python?
I’m using a sequence of codes to apply in a forecasting: ''' dataparse = lambda dates: pd.datetime.strptime(dates, '%d/%m/%Y') df = pd.read_csv('BBSE3.csv', encoding ='utf8', sep=';', parse_dates =…
-
-2
votes2
answers77
viewsSplit columns without Pandas tab
Is there any pandas method for splitting columns without separator? would be a kind of excel ext.text. I have a base with a 20-character column, but I only need the interval between 11 and 14. ex.…
-
-2
votes1
answer617
viewsError reading csv file in Python
When reading a file .csv in python generates the error below. The file is too big and I can’t open it. Someone knows how to proceed and what error is this ? import pandas as pd dados =…
-
-2
votes1
answer31
viewsPandas - Exhibition after groupby
How do I make sure the Offices column does not go blank, thus repeating the office name? mun_df = planta_df[['Empresas', 'Escritórios', 'Municípios', 'Estados']] mun_df = mun_df.groupby(['Empresas',…
-
-2
votes1
answer97
viewsGetting HTML attributes with python
I’m wanting to get the information from arial-label, href and title tag a down: <a aria-label="AS MAIS TOCADAS NO BAILE FUNK 2019 #1 - SET DE FUNK by Funk 24por48 10 months ago 39 minutes…
-
-2
votes1
answer50
viewsExtract text from a python string
I have the following difficulty. I have a df with several columns and one of them is Description. In the middle of this description I have the product code and would like to extract this information…
-
-2
votes1
answer35
viewsPython - Error import pandas
People I’m in trouble when I try to use pandas in my project, see this mistake: File "c:\Users\jua2544825\Desktop\front_reembolso\main.py", line 10, in <module> from pandas import read_csv as…
-
-2
votes1
answer136
viewsRemove lines less frequently from pandas.dataframe
I own a dataframe with more than 13000 lines and would like to remove some based on the frequency with which they appear taking into account the column named variedade. df.variedade.value_counts()…
-
-2
votes0
answers12
viewsHow do I list only pairs with USDT, Eliminating pairs with UPUSDT AND DOWNUSDT?
import pandas as pd data = pd.read_json('https://api.binance.com/api/v1/ticker/allPrices') print(data)
-
-2
votes1
answer782
viewsInitial values of an exponential moving average in python pandas
Hello, I’m trying to implement the calculation of an exponential moving average with the python pandas package. I know there are several ways of exponential weighting for a moving average, but the…
-
-2
votes1
answer64
viewsHow to find the accuracy between two columns of a data frame?
I have two columns of the same order csv, one that was written and the other that should have been written. I have three questions 1 How do I find the accuracy between them (or the more the lines in…
-
-2
votes1
answer197
viewsNumeric types to Aggregate error
I’m making a program based on a file .csv, but when I run the program the error occurs No numeric types to aggregate. File part: datatime,app version,gender,money 02/09/2019,4,F,$7.43…
-
-2
votes1
answer132
viewsPandas error 302; read_html()
I need to import a table that is in html using pandas, but when trying to do this the same returns me error. import pandas as pd url =…
-
-2
votes1
answer30
viewsIn a df, how to select items in column with datetime format, classify them into periods (morning, afternoon and evening) and place them in a new column
Hello!!! I am looking for help to solve the problem below. My df has a ' DATA column with format 29/01/2019 17:50:11), which by default is converted to 'object' type pandas. All in all, it has 640…
-
-2
votes1
answer98
viewsHow do I inform pro python that an excel cell is blank
I need to inform python that if the cell "Relation" is in WHITE, it jumps to the next page and if it is filled it fills with the cell content. The code is working normally when the cell is filled,…
-
-2
votes1
answer43
viewsHow to relate a column A to B where column B starts with special characters?
I have the df as indicated in the image, and would like the user to search the element of column B and return the element of column A corresponding... What I was able to do was the reverse only,…
-
-3
votes1
answer602
viewsHow to sort a column in the pivot_table Pandas
Here’s the thing, I need to sort a pivot table to show me the values from highest to lowest. impute_grps = df.pivot_table(values=["winPlacePerc"], index=["matchType"], aggfunc=np.count_nonzero)…
-
-3
votes1
answer35
viewsHow do I read multiple files and save them?
lista = glob.glob('/content/drive/My Drive/LOCAIS/*.xlsx') lista df = [pd.read_excel(file) for file in lista] df #melhorar dados =…
-
-3
votes1
answer47
viewsHow to delete an element in python
I have a database. created a variable and assigns values from a column to it x1 = dataobitos.SEXO there are three distinct values: "F", "M", "Undefined". I need to eliminate "Indefinite," but I…
-
-3
votes3
answers174
viewsCondition "If" does not enter the structure
I’m having a problem with my code,I get an xlsx file, and I do the whole procedure correctly. but the file comes with some commas that need to be removed, and when I do the if to check if it has the…
-
-3
votes1
answer57
viewsError while using pandas in pycharm to read excel file
I am trying to use pandas in pycharm to read an excel file but it returns me many errors as appears in the image, I have tried to change the file path,use r before the way, at last nothing is right…
-
-3
votes1
answer33
viewsSeparate Dataframe Column in List
I have a Dataframe with three columns: Categoria Label Porcentagem Cat1 Label1 40 Cat1 Label2 10 Cat1 Label3 25 Cat1 Label4 25 Cat2 Label1 50 Cat2 Label2 50 Cat3 Label3 100 I need to turn the…
-
-3
votes1
answer48
viewsTurn a column into several other columns into a pandas data frame
Good morning! I need a help... I’ve tried several commands but I think I’m going a long way. I have this dataframe: And I need to turn this:…
-
-3
votes2
answers1618
viewsDate conversion problem (DD/MM/YYYY to YYYY-MM-DD) with 'pd.to_datetime()' - Python
I’m starting in the world of Python and I’m trying to develop a simple code to identify the expiration period of digital certificates where I work (it’s a personal project, but taking advantage of a…
-
-3
votes1
answer381
viewsFrequency Table with two variables
Hello, I’m having a doubt that I can’t find the answer. I have a data set from a Statistics book that I’m studying Link to the dataset. When imported it appears as in the image. . What I would like…
pandasasked 4 years, 2 months ago Gustavo Oliveira 3 -
-3
votes1
answer323
viewsCreate dataframe pandas by dicionario 1 key and 1 value
How do I create a Data Frame Pandas through a dictionary counting only 1 key and 1 value dic = {'banco': 0, 'correndo': 1, 'da': 2, 'de': 3, 'depois': 4, 'descasnando': 5, 'foi': 6, 'ladrão': 7,…
-
-3
votes1
answer242
viewsUnable to Import csv file into pandas
Good guys, I’m trying to import a csv file into pandas through the code below: import pandas as pd data = pd.read_csv('pop.csv') He can’t find the file under any circumstances! Note: The file is in…
-
-3
votes1
answer84
viewsCreating a Register Program with Pandas and Python
I’m creating an expense control to be used as a data science study. This is my expression: def cadastro(): descritivo = [] valor = [] condicao = [] mes = input('Qual o mês vigente: ')[0:3].upper()…
-
-3
votes1
answer70
viewsHow to join three or more CSV files with something like PROCV and concatenating certain columns
Arquivo1.csv Codigo Nome Catego Geral Model Ano A1 JOGO LAMA FZ25-A|YS250|FA250AB 44CF 2017 A2 EMBLE LAMA FZ25-A|YS250|FA250AB 44CF 2017 A3 TUBO ADMI FZ25-A|YS250|FA250AB 44CF 2017 A4 PRESI ADMI…
-
-3
votes1
answer44
viewsPANDAS - PYTHON - FIND DIFFERENT VALUES
Good afternoon to you all! I’m starting some Python studies and to put into practice I’m trying to optimize some routines for my work. In the sector where we work we have the habit of crossing a lot…
-
-3
votes0
answers19
viewsUpdating a Gsheet with Gspread and pandas
I am getting a bit to use python and am trying to update a google sheet through gspread and reading a CSV that is on my pc with pandas. my code stayed: import gspread from…
-
-4
votes2
answers80
viewsFilter column value and extract from these rows in another column the value and write to a new column
I need some help, I’m getting laid. I have the title as shown in the table on the left and need to transform with Pandas in the format of the table in yellow, will the account Pandas? I am with 3…
-
-4
votes2
answers50
viewsPython - Doubt-transform into Dataframe
good morning! People connected using python in Sql database using pymssql import pymssql conn = pymssql.connect(server='nomeservidor', user='usuario', password='senha', database='banco') cursor =…
-
-5
votes3
answers248
viewsRegex - take only the first occurrence of a word in Python?
In a string, there are several occurrences of a word, but I want to take only the first occurrence of this, how to do? Below comes 'first' twice, but I wish only the first. re.findall(r'primeiro','…