pivot

How to solve 'The column label 'Avg_Threat_Score' is not unique.'? suing pandas

北城以北 提交于 2020-06-28 05:53:10
问题 When running the code I am facing following error. error - The column label 'Avg_Threat_Score' is not unique. I was creating a pivot table and wanted to sort the value from high to low. pt = df.pivot_table(index = 'User Name',values = ['Threat Score', 'Score'], aggfunc = { 'Threat Score': np.mean, 'Score' :[np.mean, lambda x: len(x.dropna())] }, margins = False) new_col =['User Name Count', 'AVG_TH_Score', 'Avg_Threat_Score'] pt.columns = [new_col] #befor this code is working, after that now

How to check if multiple items are selected in a pivot table?

二次信任 提交于 2020-06-27 17:45:08
问题 Is it possible to know which items are checked in a PivotTable filter in case MultipleItems are allowed? I only see .Visible property to check it but it only works if multiple items are not allowed. If multiple items are allowed and checked .Visible property, you only see "ALL" instead of all items selected. Any way to do it? Dim pvt As PivotTable Dim fld As PivotField Dim itm As PivotItem Dim flt As PivotFilter Dim i As Integer Set xbFuente = ThisWorkbook Set xlDatos = xbFuente.Worksheets(

Pivot table cannot find difference between January current year to December of previous year. Excel 2010

假装没事ソ 提交于 2020-06-22 22:35:32
问题 I am weeks into making my first ever pivot tables, cant believe the power of them but have hit a snag I cannot overcome. I have a worksheet which has a column with raw data (manually imputed) Then I have another 2 columns that calculate the difference from the previous month and the % difference. This works fine. As you can see January 2015 is blank as the difference field is looking for the previous month and January is the first month. how can I get it to understand to look at December 2014

PIVOT Query multiple joining

霸气de小男生 提交于 2020-06-17 06:21:55
问题 I have three tables as below. submission1_header Submission1_id Submission2_id Name 100 500 Rahul 200 500 Deva submission1_details Submission1_id Submission2_id Question_no Answer 100 500 1 YES 100 500 2 YES 100 500 3 NO 100 500 4 NO 100 500 5 YES 200 501 1 YES 200 501 3 YES 200 501 4 YES submission2_details Submission2_id Question_no Answer 500 1 YES 500 2 YES 501 1 YES 501 2 YES 501 3 NA Using below query I got the output as below (which is joining first two tables only) =================

How to pivot a dataframe

余生长醉 提交于 2020-06-17 06:21:48
问题 What is pivot? How do I pivot? Is this a pivot? Long format to wide format? I've seen a lot of questions that ask about pivot tables. Even if they don't know that they are asking about pivot tables, they usually are. It is virtually impossible to write a canonical question and answer that encompasses all aspects of pivoting.... ... But I'm going to give it a go. The problem with existing questions and answers is that often the question is focused on a nuance that the OP has trouble

How to pivot a dataframe

六眼飞鱼酱① 提交于 2020-06-17 06:21:17
问题 What is pivot? How do I pivot? Is this a pivot? Long format to wide format? I've seen a lot of questions that ask about pivot tables. Even if they don't know that they are asking about pivot tables, they usually are. It is virtually impossible to write a canonical question and answer that encompasses all aspects of pivoting.... ... But I'm going to give it a go. The problem with existing questions and answers is that often the question is focused on a nuance that the OP has trouble

SQLite query to get table based on values of another table

岁酱吖の 提交于 2020-06-16 04:06:40
问题 I am not sure what title has to be here to correctly reflect my question, I can only describe what I want. There is a table with fields: id, name, city There are next rows: 1 John London 2 Mary Paris 3 John Paris 4 Samy London I want to get a such result: London Paris Total 2 2 John 1 1 Mary 0 1 Samy 1 0 So, I need to take all unique values of name and find an appropriate quantity for unique values of another field (city) Also I want to get a total quantity of each city Simple way to do it is

SQLite query to get table based on values of another table

时间秒杀一切 提交于 2020-06-16 04:06:32
问题 I am not sure what title has to be here to correctly reflect my question, I can only describe what I want. There is a table with fields: id, name, city There are next rows: 1 John London 2 Mary Paris 3 John Paris 4 Samy London I want to get a such result: London Paris Total 2 2 John 1 1 Mary 0 1 Samy 1 0 So, I need to take all unique values of name and find an appropriate quantity for unique values of another field (city) Also I want to get a total quantity of each city Simple way to do it is

SQLite query to get table based on values of another table

自古美人都是妖i 提交于 2020-06-16 04:06:01
问题 I am not sure what title has to be here to correctly reflect my question, I can only describe what I want. There is a table with fields: id, name, city There are next rows: 1 John London 2 Mary Paris 3 John Paris 4 Samy London I want to get a such result: London Paris Total 2 2 John 1 1 Mary 0 1 Samy 1 0 So, I need to take all unique values of name and find an appropriate quantity for unique values of another field (city) Also I want to get a total quantity of each city Simple way to do it is

How to melt pairwise.wilcox.test output using dplyr?

对着背影说爱祢 提交于 2020-06-09 05:44:45
问题 I want to apply pairwise.wilcox.test function using dplyr package. I am using the following code library(tidyverse) tbl_df(df)%>% pivot_longer(cols = -Class, names_to = "Wavelengths", values_to = "value") %>% group_by(Wavelengths) %>% summarize(pairwise.wilcox.test(value, as.factor(Class), p.adjust.method="bonf")$p.value) It is giving me the following error Error: Column pairwise.wilcox.test(try$value, as.factor(try$Class), p.adjust.method = "bonf")$p.value must be length 1 (a summary value),