logo
down
shadow

find largest value in an array if value in first column matches specified value


find largest value in an array if value in first column matches specified value

By : Jamal Uddin
Date : November 19 2020, 03:01 PM
I wish this helpful for you I'm trying to find the largest or max value in an array/range (E44:I205) among rows with values in column D (D44:D2015) that match a word. For instance: , Use:
code :
=AGGREGATE(14,6,E25:I205/(RIGHT(D25:D205,3)="cat"),1)


Share : facebook icon twitter icon
find the index of largest, 2nd largest or third largest in a row of multidimensional array pyhton

find the index of largest, 2nd largest or third largest in a row of multidimensional array pyhton


By : Etim Mkpanam
Date : March 29 2020, 07:55 AM
Any of those help Let say I have the following two numpy arrays: , Here's one that scales well for generic ndarrays -
code :
def maxindex(a, b, fillna=-1):
    sidx = a.argsort(-1)
    m = np.isin(sidx,b)
    idx = m.shape[-1] - m[...,::-1].argmax(-1) - 1
    out = np.take_along_axis(sidx,idx[...,None],axis=-1).squeeze()
    return np.where(m.any(-1), out, fillna)
In [83]: a
Out[83]: 
array([[ 1,  4,  6,  2,  5],
       [ 3,  2,  7, 12,  1],
       [ 8,  5,  3,  1,  4],
       [ 6, 10,  2,  4,  9]])

In [84]: b
Out[84]: array([0, 1, 4])

In [85]: maxindex(a, b) # all rows
Out[85]: array([4, 0, 0, 1])

In [86]: maxindex(a[1], b) # second row
Out[86]: array([0])
In [105]: a
Out[105]: 
array([[[ 1,  4,  6,  2,  5],
        [ 3,  2,  7, 12,  1],
        [ 8,  5,  3,  1,  4],
        [ 6, 10,  2,  4,  9]],

       [[ 1,  4,  6,  2,  5],
        [ 3,  2,  7, 12,  1],
        [ 8,  5,  3,  1,  4],
        [ 6, 10,  2,  4,  9]]])

In [106]: maxindex(a, b)
Out[106]: 
array([[4, 0, 0, 1],
       [4, 0, 0, 1]])
Find the column in the right of the column with the largest and second largest number

Find the column in the right of the column with the largest and second largest number


By : user2437791
Date : March 29 2020, 07:55 AM
help you fix your problem
code :
i = grep('i',names(data),invert = T)
j = t(apply(data[i], 1,order,decreasing =T)[1:2,])

data.frame(data,
  matrix(names(data[i])[j],ncol = 2,dim = list(NULL,c('max','2ndmax'))),
  matrix(data[-i][cbind(c(row(j)),c(j))],ncol = 2,dim = list(NULL,c('maxi','2ndmaxi'))))
 A Ai B Bi C Ci max X2ndmax maxi X2ndmaxi
1 1  4 2  6 3  5   C       B    5        6
2 2  5 3  5 2  6   B       A    5        5
3 3  6 1  4 1  4   A       B    6        4
structure(list(A = 1:3, Ai = 4:6, B = c(2L, 3L, 1L), Bi = 6:4, 
    C = 3:1, Ci = c(5L, 6L, 4L)), class = "data.frame", row.names = c(NA, 
-3L))
Find 2nd largest value in an array that has duplicates of the largest integer

Find 2nd largest value in an array that has duplicates of the largest integer


By : user2534175
Date : March 29 2020, 07:55 AM
I hope this helps you . You can simply create a Set first and than sort in descending and take the 1st index element
code :
let array = [0, 3, 2, 5, 5]

let op = [...new Set(array)].sort((a,b) => b-a)[1]

console.log(op)
let array = [0, 3, 2, 5, 5]

let max = -Infinity
let secondMax = -Infinity

for(let i=0; i<array.length; i++){
  if(array[i] > max){
    secondMax = max
    max = array[i]
  }
}

console.log(secondMax)
How to find single largest value from all rows and column array in Python and also show its row and column index

How to find single largest value from all rows and column array in Python and also show its row and column index


By : celalang
Date : March 29 2020, 07:55 AM
hop of those help? Use numpy.unravel_index for indices and create DataFrame by constructor with indexing:
code :
df = pd.DataFrame({'Exat0': [10, -20, 3, 2], 
                   'Exat10': [20, -36, 4, 4], 
                   'Exat20': [-30, -33, 8, 7], 
                   'Exat30': [23, -38, 8, 6],
                   'Exat40': [28, 2, 34, 22], 
                   'Exat50': [18, -10, 4, 20]}, index=[1000, 2536, 3562, 2561])
df.index.name='EleNo.'
print (df)
        Exat0  Exat10  Exat20  Exat30  Exat40  Exat50
EleNo.                                               
1000       10      20     -30      23      28      18
2536      -20     -36     -33     -38       2     -10
3562        3       4       8       8      34       4
2561        2       4       7       6      22      20
a = df.abs().values
r,c = np.unravel_index(a.argmax(), a.shape)
print (r, c)
1 3

df1 = pd.DataFrame(df.values[r, c], 
                   columns=[df.columns.values[c]], 
                   index=[df.index.values[r]])
df1.index.name='EleNo.'
print (df1)
        Exat30
EleNo.        
2536       -38
r1, c1 = df.abs().stack().idxmax()
df1 = df.loc[[r1], [c1]]
print (df1)
        Exat30
EleNo.        
2536       -38
df = pd.DataFrame({'Exat0': [10, -20, 3, 2], 
                   'Exat10': [20, -36, 4, 4], 
                   'Exat20': [-30, -33, 8, 7], 
                   'Exat30': [23, -38, 8, 6],
                   'Exat40': [28, 2, 34, -38], 
                   'Exat50': [18, -10, 4, 20]}, index=[1000, 2536, 3562, 2561])
df.index.name='EleNo.'
print (df)
        Exat0  Exat10  Exat20  Exat30  Exat40  Exat50
EleNo.                                               
1000       10      20     -30      23      28      18
2536      -20     -36     -33     -38       2     -10
3562        3       4       8       8      34       4
2561        2       4       7       6     -38      20

s = df.abs().stack()
mask = s == s.max()

df1 = df.stack()[mask].unstack()
print (df1)
        Exat30  Exat40
EleNo.                
2536     -38.0     NaN
2561       NaN   -38.0

df2 = df.stack()[mask].reset_index()
df2.columns = ['EleNo.','cols','values']
print (df2)
   EleNo.    cols  values
0    2536  Exat30     -38
1    2561  Exat40     -38
How to find the largest, 2nd, 4th, 8th...2^logn th largest element in an array, use O(n) algorithm

How to find the largest, 2nd, 4th, 8th...2^logn th largest element in an array, use O(n) algorithm


By : Shyam
Date : March 29 2020, 07:55 AM
I wish this helpful for you Since this looks like a homework question, I won't give a full answer. However, here are a few helpful hints:
Do you know how to find the kth largest element in an array in time O(n)? If not, you probably need to look this up before you're going to make any progress. 1 + 2 + 4 + 8 + ... + 2log n = 2n - 1, which is O(n). Use the algorithm from part (1) on intelligently-chosen arrays. The summation from (2) will help you prove that you have the runtime bound you need.
Related Posts Related Posts :
  • Getting dictionary from arrays obtained as response in swift 3
  • Azure Stream Analytics–Querying JSON Arrays of arrays
  • Broadcasting in R
  • How to use a UDF with cell ranges in a worksheet?
  • Create groups from an unstructured data array using Ramda or similar
  • Check if bash array values are all same
  • mongodb filter and project only matched subdocuments
  • how to return the data like a array form remote store extjs
  • Filter a struct array according to a NSPredicate SWIFT
  • Observable of array to array (Rxjs)
  • Number of subarrays with range less than k
  • What is the Best Practice? Browser extension store JSON data
  • PowerShell - How to get the value of PsObject property from an array?
  • Importing data from multiple .csv files into single DataFrame
  • can't push EJS variable into array in html scripttag?
  • Values assigned to Array are stored as numbers, not as text
  • VBA Excel: Array of cells including merged cell values
  • Bash append to end of array element
  • Ruby group integer array to range array
  • How to push data in array stored in the Firebase using angularfire2?
  • Golang confusion with structs
  • Problems when trying to use arrays in APL. What have I missed?
  • chisel sorting of an array with index
  • WatchConnectivity, How to Share an Array between iPhone and Apple Watch
  • UserDefaults.standard.set(Image Array) takes more than 10 second
  • Generics in Sequence Extensions
  • How to convert JSON to Dictionary in Swift 3 Vapor
  • Access value by using a key in an array
  • Tallying Unique Names per month using in cell formulas
  • Why can't you put a variable as a multidimensional array size in Go?
  • What is the difference between filter(_:).first and first(where:)?
  • Creating a summary column in SAS from multiple columns
  • PowerShell Result Array duplicates output
  • How to Sort an array in swift based on another array element attribute
  • How to pass curl post request where there is an array in data?
  • VBA array inverse
  • How can I make an array of values after duplicate keys in a hash?
  • Spreading a given value over a given length of an array
  • Multiply each item in an array by each item in another array
  • Google Sheets Query - build referenced array source dynamically
  • Render a Nested Element based on nested Array
  • Datatransformation with PowerShell
  • For loop inside map React.js
  • ERROR: Thread 1: Signal SIGABRT (While append the element in the Array)
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org