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
votes0
answers77
viewsWord classification
I’m trying to classify the words of a Dictionarie extracted from the Tesseract when analyzing an image with standardized texts like these: Note: The "RATING" column has been added to illustrate the…
-
1
votes1
answer6569
viewsHow to join the lines of two Dataframes with Python?
Hello! I need to join lines of two dataframes with python - pandas. For example, let’s say I have these two dataframes X | Y | Z 1 | 2 | 3 4 | 5 | 6 and A | B | C 7 | 8 | 9 0 | 0 | 0 now I need to…
-
1
votes2
answers126
viewsPython Pandas - How to check if a "tuple" of two Series elements is contained in a set?
I have a "set" of "tuples" as follows set = {(2, 3), (2, 4), (5, 5)} My Dataframe is like this: df = pd.DataFrame( {'one': [1,2,4,1], 'two' : [5,3,2,2]}) I want to check if in each row the "tuple"…
-
1
votes1
answer395
viewsHow to add Datetime.Time in Pandas by group by?
I have a dataframe with two columns of Total CPU Time and Date, in the format below: Total Cpu Time: 00:00:14 Date : 2019-02-06 I need to do a group by Date that adds the hours (without disregarding…
-
1
votes3
answers2910
viewsHow to delete the first line in a python CSV file
I need to delete the first line of a csv file, which is the header and has no use. Before deleting the line the script should write with the same name the csv file (without the deleted line). I…
-
1
votes1
answer1062
viewsHow to convert a string to Date with the month name in English
I have a df in which the first column dates (13-mai-2019) is as string and I want to convert her to 13-Maio-2019 or 13-5-2019. I used the following code: df['Date'] = pd.to_datetime(df['Date'],…
-
1
votes1
answer399
viewsAdding column with filter in Pandas
I have a csv with three columns: +----------------------------+-----------------+--------------+ | txtDescricaoEspecificacao | txtFornecedor | vlrLiquido |…
-
1
votes1
answer507
viewsI cannot list the unique values of the dataframe
I have a dataframe with 1 million lines, I know that to list the unique values would be df['Col'].unique(), but I can’t see them all, because this method shows only the first and last lines, leaving…
-
1
votes1
answer917
viewsHow to store the result of an iteration in a new variable using python?
Good morning, everyone! I’m analyzing a conjunto de dados de compartilhamento de bicicletas. In that dataset there is a column called 'birthyear', indicating the year of birth of the user. I am…
-
1
votes2
answers717
viewsRead a.dat file and assign names to its columns using Pandas
How do I assign names in columns using pandas? For example, consider a arquivo.dat in the following format: 3.141592543 3.141592543 3.141592543 3.141592543 3.141592543 3.141592543 3.141592543…
-
1
votes1
answer1643
viewsTurning a table column into a list in Python
importances_DT = pd.DataFrame({'feature':x.columns,'importance':np.round(decision_tree.feature_importances_,3)}) importances_DT =…
-
1
votes1
answer1971
viewsImport and manipulate json in Python
I am trying to import a . json file with the following structure: short_description:She left her husband. He killed their children. Just another day in America. headline:There Were 2 Mass Shootings…
-
1
votes1
answer36
viewsHow to single lines a Dataframe Pandas that vary in just a few fields?
I have a Dataframe with the following format: And I would like to have the following result: How do I get it? Thank you.…
-
1
votes1
answer193
viewsRandom Forest with very high accuracy
I’m working with this dataset And I applied Forest Random to create a price forecast model, but the accuracy of the model is getting too high, so I’m suspicious if something is wrong. Apparently…
-
1
votes1
answer825
viewsCopy part of Dataframe where column is Null or Nan
I have the following doubt. I have the following sample dataframe: import pandas as pd df = pd.DataFrame({'A' : [4,5,13,18], 'B' : [10,np.nan,np.nan,40], 'C' : [np.nan,50,25,np.nan], 'D' :…
-
1
votes1
answer198
viewsWarning looping Python Pandas, How to make the looping differently?
Guys I’m doing this looping here: for i in range(1, len(candles)): if candles['askclose'][i]> candles['askopen'][i]: candles['Fechamento'][i]= 'alta' But the jupyternotebook always returns me…
-
1
votes1
answer175
viewsHow to select ALL lines that have a value exceeding 3 or -3 in a pandas dataframe?
Be it: data = pd.DataFrame(np.random.randn(1000, 4)) I found the following to select ALL lines that have a value exceeding 3 or -3: data[(np.abs(data) >3).any(1)] I didn’t understand Any’s…
-
1
votes1
answer562
viewsStacked dice. How to work this on pandas?
I have a table that is structured with "stacked" data, that is, all the information of a customer occupies a few first lines. Once the customer’s information is complete, the next client takes the…
-
1
votes1
answer119
viewsCreating a CSV from 3 CSV tables
I have two CSV tables and need to merge with the unusual columns in the two tables creating a single table. However, when I write the code, it is a very long time of processing and not complete. How…
-
1
votes3
answers1073
viewsHow to change CSV in Python and Pandas?
I am a beginner in Python and need a help. I have a csv file that has only one column with age data. I need to transform the integers into ranges, like "ate_21_anos", "ate_24_anos", etc. The problem…
-
1
votes1
answer730
viewsRead a JSON file and print the data in tabular format
The file is "grids.json", whose structure is: {"students": [{"name": "Alan", "lastname": "Silva", "exam1": 50, "exam2": 80, "exam3": 91}, {"name": "Paula", "lastname": "Souza", "exam1": 95, "exam2":…
-
1
votes0
answers88
viewsPython - How to organize an excel line from python?
Hello, this is my first question here, I don’t know if I’m asking you correctly, but come on. From the "Concat" functionality of the pandas package, I am joining several excel files, the code that…
-
1
votes2
answers577
viewsGroup three commands into one
My dataframe is called f0219. The following command filters a column of this df called Typorubrica when the code is equal to 2; this filter is assigned to the variable f0219Teto; Then, another…
-
1
votes3
answers4131
viewsJoin columns in python?
Hello. I have this file (filing cabinet) where I need to merge the columns yyyy, mm, dd, hour (year, month, day and hour) into a single column, and stay in this format 20180101010000, conclusion:…
-
1
votes1
answer1192
viewsConversion of Object to float
I have a dataframe with a column with values: 0 411,90 1 394,88 2 0,01 3 0,01 In a csv file, all the columns of my df have 'Object' typing, when I try to convert the columns that have values like…
pandasasked 4 years, 7 months ago Viviane Alves Lima 41 -
1
votes0
answers92
viewsProblems in the Results print()
I’m writing a code that calculates probabilities based on a particular Excel database. When doing this in Excel I have the final result in the column "Probability3 %": Now I need to do the same, but…
-
1
votes2
answers6875
viewsDataframe - Pandas. Assigning values in columns from comparing another column
I have the following Dataframe: import pandas as pd df = pd.DataFrame({'id_emp': [1,2,3,4,1], 'name_emp': ['x','y','z','w','x'], 'donnated_value':[1100,11000,500,300,1000],…
-
1
votes0
answers39
viewsHow to create a column based on another dataframe?
I would like to know how to create a column on a dataframe based on the code of another Python dataframe. For example, I have: df A: letra c b d c a df B: letra codigo a 10 b 20 c 30 d 40 Expected…
-
1
votes3
answers16188
viewsRemoving lines from a dataframe that meet a certain condition
Hello, I am trying to manipulate a dataframe by python 3.x API pandas with some data to be analyzed, and I need to remove the lines that meet certain conditions. The dataframe has the following…
-
1
votes2
answers173
viewsReading of multiple datasets
I am trying to read Anatel’s datasets file, but it is divided by state. Is there any way I can read all the files in the folder at once? I did reading file by file and joining all in one.…
-
1
votes1
answer450
viewsSave Captured Data and Executed Commands with Python
I need to use Python to make several commands on a system, and at the same time go saving in a dataframe everything that is being done. There will be hundreds of commands per minute, for several…
-
1
votes1
answer4825
viewsManipulation of Excel in python
I would like to update excel every time the program runs, but the library only lets me write a new excel, and not update it. How can I do that? import requests from bs4 import BeautifulSoup import…
-
1
votes1
answer746
viewsAdd and subtract according to a criterion in another column
I have a f0519_grouped dataframe like the one in the image. " Unique Identification" is the code that identifies the employee of the others; "Code Item" identifies the payment; I also have the name…
-
1
votes1
answer1875
viewsRun "Procv" on a Dataframe Pandas
I have a Dataframe in pandas containing a listing with values similar to these: a e r 0 88 6 -496 1 8 2 -188 2 76 5 -482 3 78 4 24 4 19 1 -346 5 40 1 -346 6 61 0 -224 7 79 1 -346 8 64 4 24 9 86 0…
-
1
votes2
answers50
viewsDeleting lines with repeated Labels on a Dataframe
I need to delete in a dataframe lines that contain repeated labals, as highlighted in spine "B": Below is the result of how I would like it to stay after exclusion:…
-
1
votes1
answer107
viewsReplace data from one column by considering data from another in a Dataframe
I have a Dataframe with two columns B and C where the data has no relation, would like the highlighted data of the column C received the highlighted column data B, considering the same index. After…
-
1
votes2
answers141
viewsAddition of columns in csv file - Python
I’m not able to create a csv file with a new column (month). When I try to create the whole column is only with the month of December(12) but the month column should correspond to the whole number…
-
1
votes1
answer59
viewsQuestion about list(zip) command and converting dictionaries to dataframes?
I am filling some lists with strings and other numeric entries and using them to fill some dictionaries with information that I need to view alternately. Then I came to doubt, the command…
-
1
votes1
answer41
viewsHow do I create a variable with some columns of my data frame?
I have a data frame with 10 columns and wanted to extract 4 of these columns for a variable. I even tried to make a list and use the list but the code was not clean, I know there are ways to extract…
-
1
votes0
answers57
viewsError during forecast attempt using Xgbregressor
I was assembling some models for data prediction in Machine Learning and ended up stopping at an error during a prediction attempt using the Linearregressor and Xgbregressor algorithms. Below…
-
1
votes2
answers47
viewsHow to remove dtype from dataframe line?
Running the code: def novacoluna(df): coluna_adicionada = {} coluna_adicionada['retorno_diario']= df['quota_value']/df['quota_deslocada'] return pd.Series(coluna_adicionada,…
-
1
votes1
answer82
viewsHow to group data from another grouping?
I have the following dataframe: x= {"Nome": ['Carla','Rafael','Juliana','Carla','Carla','Juliana','Rafael','Juliana','Rafael'], "Salario": [1200,1500,2000,1230,1250,2050,1700,2500,1750]}…
-
1
votes1
answer464
viewsHow to group a column containing a list in pandas? - Python3
Talk to the guys! I have a problem with pandas who can’t find a solution. I have the following dataset: I wanted to make a group where, for each year, and in each category present that year, it…
-
1
votes1
answer53
viewsHow to delete null lines in a Dataframe?
I am studying a dataset for the NBA games, and I need to know how I can remove data from the dataframe that is found as "None". Because they keep me from getting the exact amount of athletes. Below…
-
1
votes1
answer79
viewsHow to select only alternate lines in a dataframe?
After greatly refining my data, I now need to just pick up the alternate lines from it. Example, Indice 239, 444, etc. An idea would be to rename these index to 0,1,2... and ask to select only the…
-
1
votes0
answers332
viewsPandas: How can I update values in dataframe?
I have two spreadsheets where one is updating the other. How can I update this data using pandas? Example, where 'b' updates 'a': a = {'campo': ['a', 'b', 'c'], 'valor': ["", None, 1]} b = {'campo':…
-
1
votes2
answers1391
viewsConcatenate two Dataframes
I need to generate a new dataframe with the concatenation of two dataframes. The following code works, but it takes a long time to run. df_concatena = pd.DataFrame() for x in range(len(df)): for y…
-
1
votes1
answer26
viewsreturn more recent files to a folder
I am trying to return the path and modification date of all files in a folder, but I am not able to return the date, only the path. code so far: from pathlib import Path import pandas as pd…
-
1
votes1
answer44
viewsPanda does not create new lines in Spreadsheet
When creating the program in Python I take some information and put it inside a list. When trying to write this list in an excel file the data ends up getting all in the same block without creating…
-
1
votes1
answer33
viewsIn Python E Jupyter Notebook, how to present a full screen record?
I’m at Jupyter Notebook working with Python. My columns are strings and very long, I need to see these complete on screen, how to do this? The image of the dataframe with the "incomplete strings":…