Category "pandas"

Need pandas groupby.count() or groupby.size.unstack() to output a dataframe I can use

So I need to count the number of occurrences of a value per year, per animal. I've managed to do it but it's outputting a single column kind of dataframe rather

Entire Pandas Column Read in as NAN from read_csv()

I'm having trouble reading in my CSV file with Pandas. It's reading in a stock dataset which contains the Date and OHLCV columns, but for some reason, it's read

How to unmelt a completely melted table

I have this dataframe df which I have melted and then using pd.pivot_table I am able to get the table structure back at least looking at the rows it seems so -

How to create a comparison plot from an Excel file with many worksheets

I want to create a plot that will have in the x axis the months and for each country it will show the Orders per month. Attempting to create a function that rea

Python: Compare values of two fields with multiple strings and add all unique values to a 3rd field

I am still a Python-Rookie and are stuck with an idea. I want to compare the values of Type1 with Type2 and add all unique values to a 3rd field. My demo data:

Replacing a value in a column with a value from the same column based upon information

I am looking for a way to do Missing value imputation. There is a table of entries over a given time, with an entry per hour done on days. There is a seperate

Calculate Mean Absolute Error for each row of a Pandas dataframe

Below is a sample of pandas dataframe that I'm working with. I want to calculate mean absolute error for each row but only considering relevant columns for valu

`pandas.to_latex` - how to make column names bold

When I'm using the pandas.to_latex function to create latex table, the column names are unfortunately not bold. What can I do to make it bold?

Failing to remove all $ in strings in a dataframe

I'm trying to remove unnecessary values in the strings in my dataframe so I can make them integers and do some math logic on them. The commas, and upward arrows

Export multiple .csv files into .txt files in one go

I have multiple .csv files with different names like ATUL.csv, ISEC.csv, XYZ.csv and so on... Every file has similar data format mentioned below: datetime

How to highlight subrow from DF

I have made a function which add subrows to an initial DF : def AddSubrows(FullDF,DF): OutputDf = pd.DataFrame([]).reset_index(drop=True) for i in range

Scikit-learn pipeline: Non-finite test scores error / Inconsistent number of samples

I have a dataframe with two columns of texts and only the POS tags (of the same texts), which I want to use for language classification. I am trying to use both

Why does column + column concatenation create arrays for some Windows accounts?

When running the below Python code, I get different results depending on the user account/admin privileges that is used. The code is saved as test.py on a Windo

Select all in pandas where column equals value and all other columns are blank

I have a DataFrame containing permissions for roles of each user, e.g. function/role role1_permissions role2_permissions role3_permissions role4_permissions ca

Pandas : How to apply a function with multiple column inputs and where condition

I have a pandas dataframe. I want to generate a new variable (column) based on multiple column inputs where the year index is greater than a certain value. The

SettingWithCopyWarning Python3

I am finding the max of df2 by row, and setting the max value to new col on df1. df1['max'] = df2[df2.keys().tolist()].max(axis=1) This line is throwing a Sett

how to read a csv file edited from excel in python?

Hi I tried loading the csv file that has been edited and saved as csv comma delimited. However it's not loading right. I used the normal pd_read_csv like so. df

How to replace nan with a certain value across rows but only between values

I have the following dataframe, and I want to replace nan with a certain value, let's say, 0.0001, only if there is a value right to the missing value. ID 2021_

pandas scraping html tables

There is an HTML file of tables. There are about 100 of them, and they all often have the same values. The values in the second and first column of all tables a

Python Rolling sum for 32 bit vs 64 bit

I am getting strange results when doing rollingSum for 64 bit vs 32 bit precision. Please see the code for display 1 vs 2. Display 1 shows the right rolling sum