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
answer37
viewsDrop values from a dataframe based on a boolean value
When I read a CSV file, these are the first 5 lines: Shape Reported Time 1 OTHER 6/30/1930 20:00 3 DISK 6/1/1931 13:00 4 LIGHT 4/18/1933 19:00 5 DISK 9/15/1934 15:30 6 CIRCLE 6/15/1935 0:00 I want…
-
1
votes1
answer36
viewsHow to use groupBy with pd. Cut?
I’m trying to perform a groupby with the pd.cut() function, but I’m getting weird results. I have the following columns: jul/16 Ago/16 R$ 34.252,00 R$ 52.000,00 R$ 33.850,00 R$ 33.850,00 R$…
-
1
votes1
answer44
viewsMerge lists based on key column value
I am converting 2 dataframes into 2 lists. And I will group them by the CNPJ_UF_MES column (always the 1st column of each dataframe. In the real example, I will join more than 2 dataframes. After…
-
1
votes1
answer89
viewsFilter Dataframe pandas with two or more conditions
I am creating a chart with dataset tips, for this I need to filter the data based on two or more conditions. My goal is to count the number of men, and the number of women. And also count only the…
-
1
votes1
answer25
viewsPython - append in the same Dataframe
I have the following code to extract data from the yahoo that works perfectly. My problem is that I wanted to insert all the data into a single table every time it enters the FOR it go add to the…
-
1
votes1
answer24
viewsValue_counts - Pandas - Dataframe - Zero Quantity
I have a dataframe with a column of hours and the other kind of relampago.I’m making a value_counts to count the amount of relampagos every hour the day. The value_conts is working, but there are a…
-
1
votes0
answers19
viewsSlow iteration with pandas
I am using the following code to generate all chords of up to 6 elements, with 12 possible notes for each element. Then the amount of chords generated should be : (12*12*12*12*12*12) +…
-
1
votes1
answer49
viewsHow to unify by Python several repeated lines of an Excel file?
I have this spreadsheet in Excel, which is generated in the system by the pandas dataframe I can even generate the file, the problem is that it generates this way above. I need that, for example, in…
-
1
votes2
answers48
viewsReturn rows from a dataframe that are not in another dataframe
Basically, I have a Dataframe (Database) that contains all the data registered in my system: data = {"Id": ["01", "02", "03", "04",'05'],"Fruta": ['Maçã','Abacaxi','Banana','Laranja','Morango']}…
-
0
votes2
answers4543
viewsTurn columns into python pandas rows
I need to make some modifications to a dataframe but I’m not getting it. I’m using pandas. I have the table below: But I want her to stay that way? Someone can help me?…
-
0
votes1
answer4239
viewsHow to remove special character and string column point from a data frame?
raw_data = {'NAME': ['José L. da Silva', 'Ricardo Proença', 'Antônio de Morais']} df = pd.DataFrame(raw_data, columns = ['NAME']) How to transform the names of the NAME column into: Jose L da Silva…
-
0
votes1
answer1686
viewsPython/Pandas - How to remove extra space between two words from a data frame column
The "strip" function removes the spaces on the left and right, but does not remove the spaces between the words: raw_data = {'NAME': [' José Luiz da Silva ']} df = pd.DataFrame(raw_data, columns =…
-
0
votes1
answer576
viewsFiller
Good morning, I have a data frame with air temperature, global radiation and CO2, but my CO2 data are with NaN and I need to find data in other "lines" with similarity to fill Nan by CO2 data.…
-
0
votes1
answer1702
viewsHow to copy a specific data frame line to another data frame
I have following Data Frame: data = { 'País': ['Bélgica', 'Índia', 'Brasil','Índia','Bélgica','Bélgica','Russia','Brasil'], 'Capital': ['Bruxelas1', 'Nova Delhi', 'Brasília', 'Nova…
-
0
votes0
answers213
viewsAttributeerror: 'Nonetype' Object has no attribute 'fileno'
Good morning! I’m starting my study in python-pandas, and I’m having a problem that looks like simple resolution. But not for me. Yet. I’m following this tutorial:…
-
0
votes2
answers135
viewsAdding points in a known data range
I am working on data analysis using Python and for this I am training SVC and K-Means algorithms. The data used for the training have a fixed spacing between each sample, because they are sampled by…
-
0
votes1
answer692
viewsPlace data from a spreadsheet in Excel in the database
The database here of the company generates a report in Excel, I need to save this data in a database, initially sqlite3, to be able to display this data in a Django template in the future. Example…
-
0
votes1
answer106
viewsCycle gives results Nan! How to get real values?
One of the parts of my script aims to determine the area of a graph by trapezoid approximation. Within the class I created the following function that manipulates the self.df, which is a Dataframe…
-
0
votes1
answer407
viewsJoining two frames by axes
I’m a beginner in the study of programming and I have a question: I need to merge two dataframes into the date column. A data frame shows information about a bike rental company and other weather…
-
0
votes1
answer3303
viewsConvert monetary value (string) to Python/Pandas float
I’m reading a csv file where one of the columns has monetary values like '10,000.00', the pandas is interpreting as string. I wonder if I will have to convert this into race (iterating on all the…
-
0
votes1
answer458
viewsSave Excel file to Python via Scrapy
As I do for mine Spider save all Excel data in a single XML file links which I extract? Or also save in each single XLS file in the project folder? Part of my Spider: def parse(self, response): divs…
-
0
votes1
answer8561
viewsRemoving Row from Nan values of a Dataframe
I joined two tables via command pd.concat and I came across the problem of there being several Nan valoes. It turns out that there are values that are missing in one of the dataframes. To facilitate…
-
0
votes1
answer118
viewsI’m trying to get my chart started from position 0 using hist()
Using USAGE_PLOT became easy to do but I want to do and learn how to use Hist. the same way it is in the image below where it was used usage_plot(trip_data, 'duration', ['duration < 60'],…
-
0
votes2
answers4270
viewsFilter lines in pandas by a list
Given the dataframe below, I would like to filter the data of the lines according to the list 'listFilter'. nome valor 0 foo 2 1 bar 3 2 fiz 2 3 zaz 5 4 foo 6 5 far 7 6 bar 2 7 fiz 9 8 zoo 6 9 boo 3…
-
0
votes3
answers347
viewsImport csv as float
I am with the following problem, I am importing a basis for python, however I can not manipulate it (make average), by the same as str, I need to import it all values come as float.…
-
0
votes1
answer1539
viewsGroup data by Month/Year
import numpy as np import pandas as pd BASE_GERAL = pd.read_csv('base_prestadores.csv') indice | data_utilização| preço | quantidade_itens 1 | 2014-05-01 | 20.00 | 5 2 | 2014-05-08 | 30.00 | 6 3 |…
-
0
votes2
answers1260
viewsHow to paste a dataframe over a pre-formatted Python worksheet?
I have a template pre-formatted in Excel this way. I would like to paste values from a dataframe into pandas on these cells, creating a new file formatted with values and keeping the original file.…
-
0
votes2
answers6769
viewsConvert pandas data frame to array
I have a data that, from . txt, I converted to a Dataframe (DF) with pandas. For the various activities I performed it is very convenient to be a DF. There is only one column with values, beyond the…
-
0
votes2
answers65
viewsDifference between tables, criteria
I have two tables like the following:I want to get the data that are in the Table on the left and that are not in the right. Since the two tables have a common field, CPF, I want to generate another…
-
0
votes1
answer52
viewsError accessing Dictionary Code
I create a program to read from a file csv a set of coordinates and stores them in an object DataFrame. The code goes below df = pandas.read_csv(os.getcwd() + "/Coordinates.csv")…
-
0
votes1
answer108
viewsHow 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',…
-
0
votes0
answers34
viewsweb2py - show variable value with data from a.csv file in the view
I have a web2py framework project called ucsalPY with an Aplication called ucsal. The path of application is: ucsalPY/application/ucsal (/controllers, /models, /views) In the default.py controller I…
-
0
votes0
answers77
viewsCode runs on Jupyter and Error VSC
I run this code by Jupyter and it runs normally, but when I try to run this same code in Visual Studio Code it gives the following error: "File b'Salaries.csv' does not exist" says that the file…
-
0
votes1
answer290
viewsgroupby - add according to criteria
I intend to sum up all the earnings of an employee, by his Cpf, but only when he wins 100, disregarding other amounts. I’m using this code, but it’s not right: aip.groupby(['CPF']).sum()…
pandasasked 6 years ago Roger Regor 25 -
0
votes1
answer295
viewsWhat is the difference between Train Test Split and Holdout?
From what I have already researched, both divide the set into two subsets of training and testing. There is some difference between the two?
-
0
votes1
answer81
viewsPicking up data in pairs in sequential lines
I’m reading a spreadsheet csv with pandas across pd.read_csv(). The spreadsheet contains vehicle location data every moment. For example: Place 1: Latitude a, Longitude a Place 2: Latitude b,…
-
0
votes1
answer549
viewsPandas: How to merge two data frames?
Good morning Everybody! I count on your help again. I have 2 CSV, as below: # f1.csv num ano 76971 1975 76969 1975 76968 1975 76966 1975 76964 1975 76963 1975 76960 1975 and # f2.csv num ano dou url…
-
0
votes1
answer4440
viewsConcatenate pandas dataframes with different column names
I have two pandas Dataframes that I would like to match into one. They have the same number of columns in the same order, but have headers with different names. Is there any approach to efficiently…
-
0
votes0
answers407
viewsComparing two python data frames
Good afternoon gentlemen. I am new to python, and to programming. I am trying to compare two different data frames, each with the data of cars of a specific year. For now I’ve done the following:…
-
0
votes1
answer3305
viewsIn 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…
-
0
votes1
answer869
viewsIn 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
answer272
viewsError creating column in Pandas dataset
Hello, I am creating a project in python using Pandas and I want to create a column whose values are the column Closed - Open, but there is an error that I cannot solve. My code: import pandas as pd…
-
0
votes1
answer2655
viewsPandas iterrows, how to make the second looping using index
for index, row in candles.iterrows(): if (row['Twintower'] == 1): I would like to make a second looping from the moment he finds this condition, ie from this index down, or Row down, tried several…
-
0
votes1
answer985
viewsHow 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 =…
-
0
votes1
answer25
viewsHow to add a sheet to a pre-existing xlsx file with pandas?
Follow my attempts. And still unsuccessful. import pandas as pd def data_frame(): return pd.DataFrame([{'link': 'http://brito.blog.incolume.com.br', 'title':'Blog'}{'link':'http://google.com',…
-
0
votes0
answers63
viewsRaise Xlrderror - Indicating Sheet_name Python
Good morning. I’m starting with Python and I have a problem. I have N files in Excel and need to read the sheet_name of each indicating their name, the code I have so far is this: os.chdir("work…
-
0
votes1
answer240
viewsHow 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
answer2054
viewsAccessing an element in pandas dataframes
I would like to access the first element of the pandas dataframe. import pandas as pd data = [['2019', '0000', 'protocolo'], ['2020', '1111', 'pedido']] df = pd.DataFrame(data) Trying: df =…
-
0
votes2
answers2055
viewsCustomize / set the order X-axis graph matplotlib bars
I generated a chart with values for each year from 2011 to 2015. but the graph generation, on the X axis, the years are grouped according to the values, not in the correct sequence (2011, 2012,…
-
0
votes1
answer227
viewsPandas: How to make a Serie fragment in the field (Column) of the Dataframe
I have this excel below: NÚMERO "URL NÚMERO 16571 SICAN" "URL DECRETOS 2011 PRINCIPAL" 1 CCIVIL_03/Atos/decretos/1991/D00001.html CCIVIL_03/decreto/1990-1994/D0001.htm 4…