max
Select column value where other column is max of group
For SQL Server (and other products with windowed functions): SELECT * FROM ( SELECT *, ROW_NUMBER() OVER (PARTITION BY ID ORDER BY value desc) as rn FROM UnnamedTable ) t WHERE t.rn = 1
Finding the Max value in a two dimensional Array
Another way to solve this problem is by using function numpy.amax() >>> import numpy as np >>> arr = [0, 0, 1, 0, 0, 1] , [0, 1, 0, 2, 0, 0] , [0, 0, 2, 0, 0, 1] , [0, 1, 0, 3, 0, 0] , [0, 0, 0, 0, 4, 0] >>> np.amax(arr)
What is the maximum length of an NSString object?
I would assume the hard limit for NSString would be NSUIntegerMax characters, since NSString’s index and size-related methods return an NSUInteger. Since all devices currently capable of running iOS are 32 bit, this means NSUIntegerMax is 2^32 – 1 and NSString can hold a little over 4.2 billion characters. As others have pointed out, though, … Read more
What’s the maximum size of a numpy array?
You’re trying to create an array with 2.7 billion entries. If you’re running 64-bit numpy, at 8 bytes per entry, that would be 20 GB in all. So almost certainly you just ran out of memory on your machine. There is no general maximum array size in numpy.
Sort Pandas dataframe and print highest n values
I think you can use nlargest (New in pandas version 0.17.0): print df 0 Bytes Client Ip 0 1 1 1000 192.168.10.2 1 0 0 2000 192.168.10.12 2 2 2 500 192.168.10.4 3 3 3 159 192.168.10.56 print df.nlargest(3, ‘Client’) 0 Bytes Client Ip 1 0 0 2000 192.168.10.12 0 1 1 1000 192.168.10.2 2 … Read more
MySQL: Select top n max values?
If you do: select * from t order by value desc limit N You will get the top N rows. If you do: select * from t join (select min(value) as cutoff from (select value from t order by value limit N ) tlim ) tlim on t.value >= tlim; Or you could phrase this … Read more
Using min/max *within* an Integer Linear Program
Add in an auxiliary variable, say x4, with constraints: x4 >= c1*x1 x4 >= c2*x2 x4 >= c3*x3 Objective += c4*x4