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
-
0
votes1
answer1805
viewsRemove Automatically Generated Number Column in Dataframe Pandas
I created a dataframe in pandas, everything works perfect, but when I export to Excel, it appears this first column with these numbers. I would like to remove it, but commands like . drop do not…
-
0
votes1
answer1662
viewsReplace Nan value in dataframe with a string
Hello, I’m developing a small Dataframe that stores the name and symbol of some acids. I have already made the code that generates Dataframe as two separate series and concatenate them in the DF…
-
0
votes0
answers56
viewsVLOOKUP IN PYTHON USING MERGE
I have a dataframe called df with a column of countries in several languages and another dataframe called ct that I have a column with countries in several languages and another column with the same…
-
0
votes1
answer4221
viewsHow to turn a list into dataframe pandas?
I am new in the language, after the execution of the following code, the result of the append made is a list. I needed this information in dataframe, but so far I could not find a way to convert…
-
0
votes1
answer569
viewsError reading a column of a file . xlsx using Python pandas library
I need to create a Python list from a column of an Excel file using the pandas library. I have already installed all library components and the files are in the same directory. from pandas import…
-
0
votes1
answer71
viewsValueerror error: 1 Columns passed, passed data had 12 Columns
I’m trying to make a Dataframe but I get this error:Valueerror: 1 passed, passed data had 12 Columns. Here’s my code: import pandas as pd colunas = ['Legenda'] conteudo2 = [['Pontos…
-
0
votes1
answer95
viewsCreate column in dataframe that contains the list of row values except null values (Nan)
Code and file used: https://github.com/CaioEuzebio/Python-DataScience-MachineLearning/tree/master/SalesLogistics I’m working on an analysis using pandas. Basically I need to sort orders by quantity…
-
0
votes1
answer63
viewsHow to use the Timestamp(). dayofweek method on a dataframe?
I started to study python a short time ago and a problem has arisen that I am not able to solve. I have a csv file containing two columns('ds' = dates and 'y'= data of any result of the respective…
-
0
votes1
answer98
viewsHow do I delete part of a string in a pandas.Dataframe
I have a Dataframe with the column Assinatura.Cadastro, but the date and time is all together. How can I leave only the hours field, excluding the date ?…
-
0
votes1
answer33
viewsSeparate a Dataframe
I would like to know a practical way of separating a Dataframe into several by the column value state. For example: AC = covid[covid['state'] == 'AC'], AL = covid[covid['state'] == 'AL'], AM =…
-
0
votes1
answer335
viewsString handling with python and pandas
I’m trying to create a function that traverses a dataset and removes characters from strings like ('? *'), and returns the already corrected column within the dataset. As an example of dataset: df =…
-
0
votes1
answer52
viewsLoad multiple Amazon S3 files
I’m trying to load multiple files that are on Amazon S3, I’m using Panda, Anaconda, but I’m in error. bg = s3.Bucket("bucket") objects = bg.objects.filter(Prefix="bucket/") for obj in…
-
0
votes1
answer101
viewsData similarity with various pandas values
I have the following list of pandas The objective of the program is to obtain the degree of similarity according to the entered data. in this case it is a program to query houses, and I have already…
-
0
votes1
answer370
viewsGroup by com Python[Nympy or Pandas] - Bring the 1st line and last line by date
Good afternoon forum colleagues. I’m having a hard time bringing the 1st line and the last row grouped by date. However, I would like to bring this data in the format I am using group By in sum or…
-
0
votes1
answer183
viewsHow to sort bar chart from larger to smaller value
I have made the following chart. I would like to sort from the highest to the lowest value. fig, ax = plt.subplots(figsize=(8,5)) sns.countplot(olist_geolocation['geolocation_state'])…
-
0
votes3
answers84
viewsDataframe Pandas - How to use a previous value other than NA for calculation
Having a dataframe as the following example: df = pd.DataFrame([['A',1,100],['B',2,None],['C',3,None],['D',4,182],['E',5,None]], columns=['A','B','C']) A B C 0 A 1 100.0 1 B 2 NaN 2 C 3 NaN 3 D 4…
-
0
votes1
answer3450
viewsHow to read an excel table in pandas by skipping the first lines without losing information?
Hello, I have a problem to solve a little complicated, I have several xls tables in which I have to remove some data, these tables are with their content organized strangely... TEXTE TEXTO TEXTO…
-
0
votes1
answer1805
viewsHow does pivot table work on pandas?
I’m new to data science and I’m trying to use the Dataframe.pivot() of the Pandas to create a heatmap but he’s returning me this mistake: Valueerror: Index contains Duplicate Entries, cannot reshape…
-
0
votes2
answers651
viewsFilter column by string specifies
I’m trying to perform a filter on my dataframe (df_movies_usa) to eliminate all other types of currency not represented by "$". The coin is in the column df_movies_usa["budget"]. I’m using the…
-
0
votes1
answer31
viewsCreate dataframe pandas 1 key and some non-standard values in the dictionary
I have a dictionary in Python: dict = {0:[['tela1'],['tela2'],['tela3']], 1:[['tela2']], 2:[['tela5'],['tela7']], 4:[['tela1'],['tela3']]} and would like to transform into a dataframe as follows: Id…
-
0
votes1
answer794
viewsReplace certain values by media in a pandas Dataframe
Hello, I have a Dataframe as image below. I would like to replace the Nan values of the QTDVENDADIARIA column with the media of the two previous records (40+27/2), in the same way the price column…
-
0
votes1
answer53
viewsHow to replace a column conditionally in Pandas?
I have a dataframe in Pandas and need to replace the value in the column semana conditionally. Where the value is 53, I want to replace with 1. cod; semana; A; 53; A; 1; A; 1; A; 2; B; 53; B; 1; B;…
-
0
votes0
answers18
viewsDoes the true value of a number change when I change its float type.?
Change my data set to float32 or float16, is changing the "true" value of my data? If I have the value 3.6, using python and reading in float64 he remains 3.6, but it changes when I put in float32,…
-
0
votes2
answers658
viewsCheck if the values of a certain Dataframe column exist in a certain list using np.Where
Hello! I’ve been trying to check if a certain value present in a certain dataframe column is present in a list, using np.Where. In other words, it would look like this: df = { 'Pais': ['Brazil',…
-
0
votes1
answer466
viewsHow to make a sequence dates in python?
I need to create a date array of 2018-01-01, 2020-01-11, the dates being nay can be continuous (eg 2018-01-01, 2018-01-02, 2018-01-03...) and include the ends. The closest I could get was: import…
-
0
votes0
answers158
viewspandas.DataFrame.Loc
I have the following situation: d= {'files': ['f1.txt', 'f2.txt', 'f3.txt'], 'url': ['url1', 'url2', 'url3'], 'nav': [False, True, False]} df = pd.DataFrame(d) files url nav 0 f1.txt url1 False 1…
-
0
votes2
answers73
viewsI can’t understand my mistake with FOR and Dataframe
I have a problem in my for, where all the results are coming out as the same value within Dataframe, but I can’t understand the error, someone could help me import pandas as pd…
-
0
votes0
answers17
viewsCondition for file name
I need to make the following condition if the file name, which is a . json, has the characters VG, AP or GM pandas: if name_arquivo.str.contains('_VG_') or name_arquivo.str.contains('_AP_') or…
-
0
votes1
answer164
viewsTransform column with Nan and string to integer
I have a dataframe with the following column: Years 0 1990 1 1990 2 1990 3 1991 5 NaN 4 1994 6 NaN ... ... Name: Years, Length: 9742, dtype: object I have already performed part of the cleaning of…
-
0
votes1
answer74
viewsResult in a Python Dataframe
I have the following code: import numpy as np import pandas as pd import psutil as ps names = [] for service in ps.win_service_iter(): info = service.as_dict() listOf = [("Name:%s; "…
-
0
votes2
answers48
viewsHow do I delete a line that contains letters in a dataframe?
I want to exclude lines containing letters in that dataframe dic = {'Código':dataframe['Cod'], 'Dimensões': list_no_x} new_dataframe = pd.DataFrame(dic) print(new_dataframe) The way out is like…
-
0
votes0
answers16
viewsI can’t change the size of a picture - Matplotlib
I need to create a figure in bars, I’m trying to increase the size, as follows: plt.figure(figsize=(8,8)) plt.bar(df_nacoes_ano) plt.show() But I get the following message: TypeError: bar() missing…
-
0
votes0
answers113
viewsCode error (Python, Pandas and Excel)
I made a code to pick the time and day of the week and so picks up the cell of the excel spreadsheet and should inform me, but it is going wrong when picking up, besides on Tuesday (incicaçao ES)…
-
0
votes1
answer24
viewsSort data in dataframe pandas by repeating frequency of each element
I have a dataframe and I want to organize the data by the frequency of appearance of each element. From the most repeated to the least repeated, to create a ranking. I want the organization to be…
-
0
votes1
answer31
viewsIs it possible to replace certain values with NA in pandas without the use of loops?
I was studying data cleaning, and I saw that sometimes there can be int values in columns that should be string and vice versa, so the solution given by the author of the publication I was reading…
-
0
votes1
answer27
viewsPrintable images with the Pillow library
I am developing an automatic certificate issuance project where I use the pandas to pull the names of a spreadsheet and Pillow to write the names in the certificate. The problem occurs when printing…
-
0
votes1
answer119
viewsPopulating a dictionary of dictionaries through a for loop
I’m trying to create a loop to add information in a dictionary. The most external key of the dictionary will be the name of a course, and the value will be another dictionary, there will be 6 keys,…
-
0
votes1
answer14
viewspivot_table of frequency
I want to build a pivot_table on pandas that counts frequency. For example, I have a sex column, with 2 options, one of UF, with 5 options, and one of color, with 4 options, I wanted to make a table…
-
0
votes0
answers13
viewsGroupby with pandas and matplotlib
How to group the total value of y per year x and plot? x = df_Year y = df_RevenueMillions plt.plot(x, y) plt.show()…
-
0
votes2
answers768
viewsHow to fill a column of a pandas dataframe using corresponding values from another column in another dataframe?
Hello. I am working on a personal project and need a help. I have 2 dataframes: solicitacoes = pd.DataFrame({'ID':[1,2,4,5], 'Equipe':['A','B','C','D','E'], 'Emissor_da_ordem':['Joao Pedro','Maria…
-
0
votes1
answer323
viewsCalculate the average of a variable for each type of flower in a column
In the Species column of the dataset, I have these flower species: df['species'].unique() output: array(['Iris-setosa', 'Iris-versicolor', 'Iris-virginica'] I need to average for each flower species…
-
0
votes1
answer81
viewsHow to use a collection as an element of a Python array?
I am developing a project using scikit-Learn (and pandas to handle the data) to predict the results of football matches based on previous results. As a project methodology, for each row of the…
-
0
votes2
answers100
viewsDataframe row and column organization
Hello, I have the following situation: import pandas as pd import numpy as np l=[] l.append(('Mod1',0,70)) l.append(('Mod1',1,88)) l.append(('Mod1',2,97)) l.append(('Mod2',0,44))…
-
0
votes1
answer243
viewsremove brackets from the values stored in a dictionary
When trying to use an excel spreadsheet as a data source for my DOCX-TEMPLATE, the dictionary I am generating is storing the values with brackets, and these and brackets are appearing in the final…
-
0
votes0
answers49
viewsDeprecationwarning in Matplotlib
Hello, I am using the version "pandas==1.0.4" and in my code below has generated the following Warning: MatplotlibDeprecationWarning: Passing the minor parameter of set_xticks() positionally is…
-
0
votes1
answer100
viewsPower BI and Python - Incomplete Script Result
Hello, I am trying to return the link list found in HTML with the python script below. When run in the Python IDE, the result returns all found occurrences. When running on Power Bi Desktop, the…
-
0
votes2
answers116
viewsWhy are the commas of the numbers being deleted when importing data with Pandas?
I’m racking my brain to understand why this is happening when I take numerical data from a table on the web. In this table contain the values of the quotations of the coins, the problem occurs that,…
-
0
votes1
answer58
viewsWorking with two different Datasets - Filter the data
Dataset - Players Dataset - Results Good night, I’m stuck in a data wipe. I am working on a project to predict the winners of a particular Counter Strike Global Offensive match, for my final course…
-
0
votes1
answer53
viewsHow to move the title from one column to another?? (web scraping-python)
I’m trying to make a web scraping, but if you view the site you notice that certain titles are on certain columns. What my program does is take the table, create two full columns of Nan and assign…
-
0
votes1
answer28
viewsDynamically merge lines that share the same key into one
I have a Dataframe. I would like to make another column that combines columns whose name starts with the same value in Answer and QID. That is, with this Dataframe exercise: QID Category Text QType…