List minimum in Python with None?
None is being returned >>> print min([None, 1,2]) None >>> None < 1 True If you want to return 1 you have to filter the None away: >>> L = [None, 1, 2] >>> min(x for x in L if x is not None) 1
None is being returned >>> print min([None, 1,2]) None >>> None < 1 True If you want to return 1 you have to filter the None away: >>> L = [None, 1, 2] >>> min(x for x in L if x is not None) 1
The analytic function approach would look something like SELECT a, some_date_column FROM (SELECT a, some_date_column, rank() over (partition by a order by some_date_column desc) rnk FROM tablename) WHERE rnk = 1 Note that depending on how you want to handle ties (or whether ties are possible in your data model), you may want to use … Read more
std::min and std::max are constexpr in C++14, which obviously means there isn’t a good reason (these days) not to have them constexpr. Problem solved 🙂
Recent manuals say: The G++ minimum and maximum operators (‘<?’ and ‘>?’) and their compound forms (‘<?=’) and ‘>?=’) have been deprecated and are now removed from G++. Code using these operators should be modified to use std::min and std::max instead. A quick search of the past documents seems to indicate that they were removed … Read more
You have max-width: 100%, but 100% of what? Of the parent width, right? But the parent is an inline-block (with class=”sponsor”) whose width is not set, so its width depends on the children, and in particular on the preferred width of the children. The layout of this styling is undefined in the CSS specification. In … Read more
The tf.reduce_max() operator provides exactly this functionality. By default it computes the global maximum of the given tensor, but you can specify a list of reduction_indices, which has the same meaning as axis in NumPy. To complete your example: x = tf.constant([[1, 220, 55], [4, 3, -1]]) x_max = tf.reduce_max(x, reduction_indices=[1]) print sess.run(x_max) # ==> … Read more
Well, as there is no date like 2014, you would expect null, because the maximum of nothing is actually not anyting. But do this: COALESCE(MAX(number),0) Which means: get the first non-null thing from the next list, so if your max is null, it’ll give you 0
This should do it: SELECT report_id, computer_id, date_entered FROM reports AS a WHERE date_entered = ( SELECT MAX(date_entered) FROM reports AS b WHERE a.report_id = b.report_id AND a.computer_id = b.computer_id )
You can use clip. Apply to all columns of the data frame: df.clip(upper=15) Otherwise apply to selected columns as seen here: df.clip(upper=pd.Series({‘a’: 15}), axis=1)
This is a typical job for NumPy, which is very fast for these kinds of operations: array_np = numpy.asarray(array) low_values_flags = array_np < lowValY # Where values are low array_np[low_values_flags] = 0 # All low values set to 0 Now, if you only need the highCountX largest elements, you can even “forget” the small elements … Read more