rank

How to add rank column?

≡放荡痞女 提交于 2021-02-20 18:56:34
问题 I would like to select records and determine rank number for each similar data. My data is as follows. MEMBER ID | LOAN AMOUNT 1 | 2,000.00 2 | 1,000.00 3 | 4,000.00 4 | 1,000.00 The result I wanted is shown below. RANK|MEMBER ID|LOAN AMOUNT 1 |3 |4,000.00 2 |1 |2,000.00 3 |2 |1,000.00 3 |4 |1,000.00 RANK is a new column. I am using MS SQL server 2008 and created a view table as shown below but it does not resulting to what is wanted. select rank=count(*), s1.MemberID, s1.Loan_Amount from

How to rank rows by id in Pandas Python

隐身守侯 提交于 2021-02-16 20:13:25
问题 I have a Dataframe like this: id points1 points2 1 44 53 1 76 34 1 63 66 2 23 34 2 44 56 I want output like this: id points1 points2 points1_rank points2_rank 1 44 53 3 2 1 76 34 1 3 1 63 66 2 1 2 23 79 2 1 2 44 56 1 2 Basically, I want to groupby('id') , and find the rank of each column with same id. I tried this: features = ["points1","points2"] df = pd.merge(df, df.groupby('id')[features].rank().reset_index(), suffixes=["", "_rank"], how='left', on=['id']) But I get keyerror 'id' 回答1: You

subroutine argument with unknown rank (shape) in fortran

廉价感情. 提交于 2021-02-16 08:34:22
问题 I am wondering how to best handle in Fortran a subroutine that takes an argument of unknown rank. For instance: Real * 8 :: array1(2,2),array2(2,2,3) call mysubroutine(array1) call mysubroutine(array2) As for now, I always need to fix the shape (number of rank) in the subroutine. For instance, the intrinsic subroutine random_number ( array ) can do. (But maybe it is not coded in Fortran?) 回答1: You have to write a specific subroutine for each array rank, but you create a generic interface so

Rank & Rank.EQ function - Array reference error

丶灬走出姿态 提交于 2021-02-11 13:58:31
问题 Background: Short question on the use of array references within RANK or RANK.EQ function. Both function got the following parameters: ....(number,ref,[order]) Ms.Documentation about the Ref parameter within RANK and RANK.EQ : " Ref Required. An array of, or a reference to, a list of numbers. Nonnumeric values in ref are ignored." Also, other websites I would normally highly recommend, would state that the use of an array or list is possible within the Ref parameter. Sample data: | Rank1 |

Rank & Rank.EQ function - Array reference error

混江龙づ霸主 提交于 2021-02-11 13:57:30
问题 Background: Short question on the use of array references within RANK or RANK.EQ function. Both function got the following parameters: ....(number,ref,[order]) Ms.Documentation about the Ref parameter within RANK and RANK.EQ : " Ref Required. An array of, or a reference to, a list of numbers. Nonnumeric values in ref are ignored." Also, other websites I would normally highly recommend, would state that the use of an array or list is possible within the Ref parameter. Sample data: | Rank1 |

Add ordered ID for each group by date

早过忘川 提交于 2021-01-29 07:56:47
问题 I want to add an ordered ID (by date) to each group in a data frame. I can do this using dplyr (R - add column that counts sequentially within groups but repeats for duplicates): # Example data date <- rep(c("2016-10-06 11:56:00","2016-10-05 11:56:00","2016-10-05 11:56:00","2016-10-07 11:56:00"),2) date <- as.POSIXct(date) group <- c(rep("A",4), rep("B",4)) df <- data.frame(group, date) # dplyr - dense_rank df2 <- df %>% group_by(group) %>% mutate(m.test=dense_rank(date)) group date m.test

Oracle SQL conditional ranking

断了今生、忘了曾经 提交于 2021-01-28 09:51:14
问题 In my query, I am doing multiple types of ranking and for one of ranking types, I want to rank the row only if certain column is not null. Else I don't want ranking to happen. For example here's a sample table: +------+------------+------------+--------+--------+ | col1 | col2 | col3 | rank 1 | rank 2 | +------+------------+------------+--------+--------+ | a | 2018-01-20 | 2018-03-04 | 2 | 2 | | a | 2018-01-24 | 2018-04-04 | 1 | 1 | | b | 2018-01-02 | 2018-05-03 | 1 | 1 | | c | 2017-01-02 |

Oracle SQL conditional ranking

泪湿孤枕 提交于 2021-01-28 09:46:43
问题 In my query, I am doing multiple types of ranking and for one of ranking types, I want to rank the row only if certain column is not null. Else I don't want ranking to happen. For example here's a sample table: +------+------------+------------+--------+--------+ | col1 | col2 | col3 | rank 1 | rank 2 | +------+------------+------------+--------+--------+ | a | 2018-01-20 | 2018-03-04 | 2 | 2 | | a | 2018-01-24 | 2018-04-04 | 1 | 1 | | b | 2018-01-02 | 2018-05-03 | 1 | 1 | | c | 2017-01-02 |

ImageMagick: custom rank filter? Like erode or dilate or median but a different rank, e.g. a 'percentile' filter?

假如想象 提交于 2021-01-28 05:40:38
问题 When applying a rank filter with ImageMagick such as erode or delate or median, it takes the minimum ( erode ) or maximum ( dilate ) or middle ( median ) value of all pixels within a certain radius or custom shape around each source pixel. Is it also possible to take a custom rank of the surrounding pixel values? For example when using a 5x5 square, with the erode or dilate or median filters, respectively the lowest, highest, of middle value of the 25 pixels surrounding each pixel is taken.

Find rank of a sub-matrix in Tensorflow

a 夏天 提交于 2021-01-27 19:07:03
问题 I have a matrix g of shape [4, 4, 2, 2] where I need to find the rank of g[0, 0] , g[1, 1] , g[2, 2] and g[3, 3] which are all 2x2 matrices. I used the tf.rank operator but it treats g as a single array and computes the rank and returns a single value for the whole matrix. What I need is a 2x2 matrix of ranks of the corresponding g[i, j] 's. Following is a MWE: import tensorflow as tf import numpy as np a = np.array([ [[[ 0., 0.], [ 0., 0.]], [[-1., -1.], [-1., -1.]], [[-2., -2.], [-2., -2.]]