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
-
2
votes1
answer55
viewsOrdering of data Pandas
I have a table . cvs and accurate Print the employee with the highest amount billed each month, including employee name and total (example: "August 2020 - João - Total Billed: 150"); I got with the…
-
2
votes2
answers55
viewsHow to calculate the average for groups and identify the maximum value?
I have a spreadsheet where I need to find the month with the highest sales average. With the code below I managed, but when I print the object appears all the disordered information as can be seen…
-
2
votes2
answers53
viewsHow to change abbreviated values in a DF using Pandas in Python
I have the following problem, I have a df with more than 50 columns, in these columns, some have value of type "35,57B", "6,85T". How do I make iteratively and replace the examples cited above so…
-
2
votes1
answer76
viewsHow do I perform a normalization of curves in python?
Good afternoon everyone, I am doing an exploratory analysis of data in Python using the classic DF kc_house_data, and I came across the following problem. I would like to make some comparisons to…
-
2
votes2
answers77
viewsIn a Dataframe, modify data from one column conditioned to the value of another column
I am working on an automation with reports for the results of cryptocurrency/stock buying and selling operations. I need to convert the positive value of a cell to negative if it is bought (BUY).…
-
2
votes1
answer46
viewsalgorithm or reasoning to get close-averaged sets from a list
I have the following list Cu, at 40 values: [1.37812, 1.25154, 1.2486 , 1.22726, 1.22645, 1.16835, 1.14414, 1.1367 , 1.05915, 1.0446 , 1.03972, 1.03597, 0.98309, 0.94804, 0.91199, 0.90972, 0.89231,…
-
1
votes1
answer1599
viewsHow to get the average sizes of a cluster with Pandas?
Given a Pandas Dataframe, with the data in such a structure: import pandas as pd raw_data = { 'tipo': ['a', 'a', 'b', 'c', 'c', 'c', 'd'], 'ano': [2000, 2000, 2000, 2001, 2001, 2001, 2001], } df =…
-
1
votes1
answer1095
viewsTransform query into dataframe [sqlalchemy + pandas]
I’m new to python and I want to create a function that will query the database[mysql] and convert it into a dataframe so that it can be sent by e-mail in format. csv. But I’m having problems in this…
-
1
votes2
answers1966
viewsPandas Soma Condicional
Hello. I have the following situation df1 = pd.DataFrame({'Key':['a','b','c','a','c','a','b','c'],'Value':[9.2,8.6,7.2,8.3,8.5,2.1,7.4,1.1]}) df2 = pd.DataFrame({'Key':['a','b','c']}) and would like…
-
1
votes0
answers45
viewsThis error happens when I run the program on Ubuntu, and Win10 works normal. What to do?
Program def trabaLinhas(caminho): colunas = extraindoZip.listaArq(caminho)[1] dadosV = pd.DataFrame(columns=colunas) for coluna in colunas: listaLinhas = lerTxt(caminho, coluna) dadosVazao = []…
-
1
votes2
answers1752
views -
1
votes1
answer755
viewsGet common values in multiple columns of a dataframe?
I have a table with numerical values and would like to take the values in common in all columns (intersection) and the unique values of each using pandas (Python). Position_a Position_b Position_c…
-
1
votes1
answer1113
viewsCompare all Rows and Columns of two Df, update and add differences at the end of Rows and Columns
I have two csv separated by tab. Both have the same number of Rows and Columns. The first column POS has the same Unique values in both df. Differences (or not), occur in the values (strings) of the…
-
1
votes2
answers397
viewsCalculate how many Nan in each Python time
Good day, I have one DF where it has NaN And I need to count how many Nan I have at every hour. My df has a 31-day period. I believe I should use Groupby, but I’m not finding a way. import numpy as…
-
1
votes1
answer186
viewsSlice proportional to dataframe size
How can I perform a Slice on the dataframe according to its line size? For example: if the dataframe has 14 lines, divide into 2 parts of 7, if it has 28 lines, divide into 3 parts of 7, and so on.…
-
1
votes1
answer1465
viewsPython/Pandas - How to compare if column content of the data frame, in date format, is equal to another date column about 1 day?
I have a date frame with two columns in date format and I need to compare if one of them is between the interval of one day more or less than another column. For example: Column A = 2015-03-02…
-
1
votes1
answer11835
viewsSort Python Data Frame (Pandas) in two levels
I have this Dataframe and I want to organize it first by name and then by year, that is, Sort it in doís levels. How can I do that? Country Name Country Code Indicator Name Indicator Code Ano…
-
1
votes1
answer425
viewsHow to sum a column of a file and visualize with . Plot(Kind = 'bar')?
I’m trying to sum up the column Duration ,and present using plot() trip_data['duration'].value_counts().plot(kind = 'bar') trip_data['duration'].count_data().plot(kind = 'bar')…
-
1
votes1
answer389
viewsProblem concatenating csv files
I’m trying to concatenate one CSV file with another. My goal is to remove data from an HTML daily and my routine should take a csv file called 'old data' where there is a dataframe saved in csv, and…
-
1
votes1
answer1608
viewsHelp with Strike Match Similarity Algorithm
Friends need a help in implementing the algorithm below that looks for similarities: import nltk import pandas as pd def get_bigrams(string): s = string.lower() return [s[i:i+2] for i in…
-
1
votes0
answers153
viewsPandas Dataframe to_html or iterate over the data in the template?
Actually I wanted to iterate on the data in the template? But how do I play my pivot’s dice in context and treat them in the template? df = pd.DataFrame(data) pv = df.pivot(index='cands',…
-
1
votes1
answer1291
viewsCreate new DF based on a Pandas column
I am new in Python and Pandas I have a DF that with 3 columns, as in the example below: SRC Data1 Data2 AAA 180 122 BBB 168 121 CCC 165 147 DDD 140 156 EEE 152 103 AAA 170 100 CCC 166 112 DDD 116…
-
1
votes1
answer1473
viewsManipulation of columns with pandas
I’m running a regression where I have 3 parameters and a column with categories. As sklearn does not recognize categories I turn them into Dummies ( create a column for each category and fill with 1…
-
1
votes1
answer608
viewsChange encoding in pd.to_datetime
wondered if there is the possibility to change the encoding of an element returned by the function to_datetime pandas. I need to switch to ISO-8859-1 encoding to compare the date with others that…
-
1
votes1
answer647
viewsSelect data from a spreadsheet
I read data from a spreadsheet using Python 3 libraries (xlrd / xlsxwriter / Pandas and Numpy). This spreadsheet has in the rows questions of the survey and in the columns the areas that answered…
-
1
votes1
answer236
viewsPython Error in if
I am having an error in the if and do not know how to correct this error, I am using Python 3.6 and Pandas for reading, writing and data analysis. df1 = pd.read_csv("JonnyTheBoy10.csv",…
-
1
votes1
answer242
viewsHow to group numeric sequences?
Friends, I have a csv file with 5k lines in which there are purchase transactions. There is an id for each purchase, it occurs that for a lot where several purchases transactions are made there is…
-
1
votes2
answers5844
viewsPython/Pandas - How to create a data frame that contains the original line and duplicate line
In a date frame that contains two lines with Pais = India, I was able to create a duplicity-free data frame with only one line from India A data frame with duplicate line only I need to create a…
-
1
votes1
answer1838
viewsDivision between column values and rows using pandas
I created a table pivot containing some values, but I do not know if it is necessary to use pivot table in this case below is a sample of the results: Valor ajuste \ Data posicao 2017-05-30…
-
1
votes1
answer4407
viewsHow to make a frequency distribution table in Python?
Good afternoon, One question: Could someone enlighten me on how I can make a frequency distribution table: classes; absolute and relative frequency; cumulative form; average values of each class.…
-
1
votes2
answers4838
viewsChanging a value with the pandas library
I’m opening a file. csv with the pandas library, but I am informed at the time of opening this file that a given column presents values of different types. I know that the character "/" was used in…
-
1
votes1
answer1156
viewskeep only rows of a column with the value with Pandas
Hello, I’m a beginner in the area and one of the exercises I’m having trouble answering is this. there is a file with several columns. In one of these columns, there are several cep(zipcode), and…
-
1
votes1
answer411
viewsimporting data extension ". date"
My Python code is loading a dataset from the internet, but the same is not recognizing the columnar number of the data. Python code: import pandas as pd ##Importando dados data =…
-
1
votes1
answer6739
viewsDate column of the Dataframe
I have this Dataframe and would like to separate the column from the date as I do it? Data e Hora Consumo(litros) Valor Acumulado 0 2017-08-21 20:00:00 65 65 1 2017-08-21 21:00:00 81 146 2…
-
1
votes1
answer2411
viewsHow to round value created on pandas?
Hello Please, in pandas Python 3 I am creating this dataframe with the sum of another dataset: total = cand_doacoes.groupby(['CPF_candidato', 'Nome_candidato', 'Cargo']).Valor.sum().reset_index()…
-
1
votes1
answer3264
viewsChange Column Data using Pandas
I’m trying to learn panda but I’m having a question here I have the following data: PSG CLASS AAA 1 BBB 2 CCC 3 DDD 1 I wanted to create a new column, using Pandas, with the name Class and with the…
-
1
votes3
answers568
viewsMemoryerror on the pandas
Hello I am using the pandas merge command in python3: ibama_doadores_orig = pd.merge(eleitos_d_s_doadores, ibama, left_on='CPF_CNPJ_doador_originario_limpo', right_on='CPF_CNPJ_limpo') But a message…
-
1
votes1
answer299
viewsBag of words in Python
I have a news dataset and I want to separate them between two classes. For this I thought about using Bag of words, but I’m not getting it with Sklearn. I tried the following: #Bag of words from…
-
1
votes1
answer28
viewsCross valdation n-fold
W1 W2 W3 W4 A/N 0 0.543405 0.278369 0.424518 0.844776 1 1 0.121569 0.670749 0.825853 0.136707 1 2 0.891322 0.209202 0.185328 0.108377 1 3 0.978624 0.811683 0.171941 0.816225 0 4 0.431704 0.940030…
-
1
votes2
answers3726
viewsTurn columns into rows into a dataframe
I have a dataframe with the columns: LUC Contrato Fantasia Ano Mes 01 02 03 05 ... 30 Tatividade I need to turn these columns with the days of the month into rows. In each column has the value sold…
-
1
votes1
answer851
viewsPython pandas formatting
import numpy as np import pandas as pd ID = [i for i in range(1,101)] def tabela(imc): if imc < 18.5: return 'Abaixo do peso' elif imc < 25 and imc >= 18.5: return 'Saudável' elif imc <…
-
1
votes1
answer6608
viewsAdd column to a dataframe based on the classification made on another dataframe
Greetings! I have two dataframes. Both have columns that determine intervals, with maximum and minimum numbers. In each dataframe the classification of each range is done in one way. I wanted to…
-
1
votes1
answer172
viewsOn big scrapings how to avoid Connectionerror?
In Python 3, I have a program to make web-scraping tables on websites. There are 5,299 pages, on each page there is a table With XHR I found the generated JSON on each page. But there is always a…
-
1
votes2
answers1572
viewsHow to invert a column in Python?
I would like to know how to invert "First Name, Last Name, Age" to "Age, First Name, Last Name" Follows my code: import pandas as pd #Importa a biblioteca "Python Data Analysis" df =…
-
1
votes1
answer1847
viewsHow to save the obtained medias in a dataframe, in a new column containing the averages of this dataframe using pandas?
Good night, I have a problem trying to save values of the average of a df, in a single column. An example of how I wanted you to stay was: Dataframe In this first part, I just opened my dataframe…
-
1
votes1
answer1784
viewsPandas: Create multiple columns in Dataframe
I have a spreadsheet with the following information: NUM_LEGISLACAO DSC_URL ... COD_TIPO DSC_TIPO 0 323/1895 NaN ... 2.0 CONCRETO 1 2.269/1896 NaN ... 2.0 CONCRETO 2 2.397/1896 NaN ... 2.0 CONCRETO…
-
1
votes1
answer1121
viewsHow to read txt file separated by "|" using Python with the Pandas library?
I have a txt file with the following structure: ----------------------------------- |SKU. |DT.Compra|Dt.Chegada|SKTD| |---------------------------------| |100312 |20171202 |20180105 | 27 | |89721…
-
1
votes1
answer156
viewsClassification of network attack data (attack or no attack)
I’m using the dataset: https://www.unsw.adfa.edu.au/unsw-canberra-cyber/cybersecurity/ADFA-NB15-Datasets/ The goal is to classify a sample as attack or no attack. A good idea would be to use…
-
1
votes2
answers6913
viewsCounting Nan and null values in a pandas dataframe
Imagine we have a CSV file called.csv data: col1 col2 col3 col4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 33 44 import numpy as np import pandas as pd po = pd.read_csv('/dados.csv') My goal is to better…
-
1
votes1
answer819
viewsHow to set the xticks equal to that figure
I’m taking a course in Python geared towards finance. Then in an exercise you are asked to plot a graph using Dataframes. So far so good, I managed to do everything right, however my xticks do not…