Skip to content

Tag: pandas

Pandas Average of row ignoring 0

I have a DataFrame that looks like this: I need to find the mean of each row, ignoring instances of 0. My initial plan was to replace 0 with NaN and then get the mean excluding NaN. I tried to replace 0 with NaN, however this didn’t work, and the DataFrame still contained 0. I tried: The second issue is

Add pivot table in excel with python

I am trying to add a pivot table in excel using python script with pandas but not able to do so. I won’t to count number of missed and met entries for each priority. Excel script: Excel data: Priority SLA p1 Met p2 Missed p3 Missed p2 Missed p3 Missed desired output: Priority Met Missed p1 1 0 p2 1

how to ignore null values in DataFrame when comparing columns

I am new to Pandas and learning. I am reading excel to DataFrame and comparing columns and highlight the column that’s not same. For example if Column A is not same as Column B then highlight the Column B. However I have some null values in Column A and Column B. When I execute the code, I don’t w…

Create new columns based on previous columns with multiplication

I want to create a list of columns where the new columns are based on previous columns times 1.5. It will roll until Year 2020. I tried to use previous and current but it didn’t work as expected. How can I make it work as expected? Answer IIUC you can fix you code with: Another, vectorial, approach with…