how to set min and max for an attribute in Julia? - struct

I have this struct and I need to set a min/max Value for it
struct Field <:AbstractModel
type::Type
default::String
description::String
min::Int
max::Int
end
for example min should not be lower then 0 and the max is 10

Related

Is it possible to get MIN and MAX VALUE with ONE priority_queue?

If I have a queue which is {1, 3, 10, 22}
and I need max and min value (22, 1)
so I made maxHeap and minHeap with priority_queue, and I got two priority_queue.
but I need just max and min. I think that I just make one maxheap and get max in root and get min in (where). If possible.
So is it possible to get MAX & MIN with just one maxheap or minheap?
Or I must make two priority queues?

How to find the min and max elements in a list that has nan in between

I have a dataframe that has a column named "score". I am extracting all the elements from that column into a list. It has 'nan's in between. I wish to identify the min and max of elements before every 'nan' occurs.
I was looking into converting the column into a list, and traverse the list until I encounter an "nan". But how do I traverse back to find the min and max elements right before nan?
This is the code I wrote to convert a column of a dataframe into a list and then identify the "nan".
score_list = description_df['score'].tolist()
for i in score_list:
print(i)
if math.isnan(i):
print("\n")
Suppose my data looks like this,
11.03680137760893
5.351482041139766
10.10019513222711
nan
0.960990030082931
nan
6.46983084276682
32.46794015293125
nan
Then, I should be able to identify max as 11.03680137760893
and min as 5.351482041139766 before the occurrence of the first "nan", 0.960990030082931 as the min and max before the occurrence of second nan and after the occurrence of first nan, and 32.46794015293125 as max and 6.46983084276682 as min after the second 'nan' and before the third 'nan'
You can create groups by testing missing values by Series.isna with Series.cumsum, aggregate by GroupBy.agg with min and max and last remove only missing rows by DataFrame.dropna:
df = df.groupby(df['score'].isna().cumsum())['score'].agg(['min','max']).dropna()
print (df)
min max
score
0 5.351482 11.036801
1 0.960990 0.960990
2 6.469831 32.467940
You can create two variables called min and max that begin with a default value each time you find a nan and print them (or store).
import sys
score_list = description_df['score'].tolist()
max = sys.float_info.min
min = sys.float_info.max
for i in score_list:
print(i)
if math.isnan(i):
print("max =", max, "min =", min, "\n")
max = sys.float_info.min
min = sys.float_info.max
else:
if i > max:
max = i
if i < min:
min = i

Excel formula for greater than but less than with several tiers

I have a few hundred rows of data, and each has a number between 1 and 200, and I'd like to put them in categories of 1-5 depending on where that number is.
The categories look like this:
Zones Min Max
1 0 35
2 35 60
3 60 85
4 85 110
5 110 200
I want to assign it a Zone if it is greater than the Min, but less than the Max.
I have 2 formulas I've been working with to solve it. One is a nested IF AND statement:
=IF(A1<=35,1,IF(AND(A1<=60,A1>35),2,IF(AND(A1<=85,A1>60),3,IF(AND(A1<=110,A1>85),4,IF(AND(A1<=200,A1>110),2,"TOO BIG")))))
The 2nd formula attempts to use a SUMPRODUCT function:
=INDEX($C$2:$C$6,SUMPRODUCT(--(A1<=$E$2:$E$6),-- (A1>$D2:$D$6),ROW($2:$6)))
Rather than have to continue to adjust the numeric values manually, I set them as absolutes, which is why this formula is slightly different. The E column is the Max value set, and the D is the Min value set.
Any help would be appreciated!
Use this:
=MATCH(A1,{0,35,60,85,110})
Another way is to use VLOOKUP and you just need to set the min number:
=VLOOKUP(D2,$A$2:$B$6,2,1)
The key is the 4th parameter needs to set to 1 which means TRUE. It will find the closest value and return the zone for you.
But noticed that you have overlaps like 35 or 60 etc. that you will need to adjust your value column.

Return value in cell based on other cells values combination in excel

I have a table in Excel that has the following columns:
My table
dm: Can be 0 or 1
gdr: Can be 0 or 1
smk: Can be 0 or 1
agemin: min age number
agemax: max age number
sbpmin: min sbp number
sbpmax: max sbp number
chlmin: min chl number
chlmax: max chl number
The table is big with all possible combinations.
What i need is a way to find the value in result based on the input of:
dm, gd, smk, age, sbp and chl. As i mention the first 3 can be a 0 or a 1 but the other 3 is a number that must be contain in the range given by the columns min and max.
Has anyone have a clue on how can i solve this?
Thanks,
Using the provided table and assuming the parameters for a lookup are in column M (as shown in the below picture), then the formula in cell M9 and copied right to get the result is:
=IFERROR(INDEX($J$2:$J$4,MATCH(1,INDEX((M2=$A$2:$A$4)*(M3=$B$2:$B$4)*(M4=$C$2:$C$4)*(M5>=$D$2:$D$4)*(M5<=$E$2:$E$4)*(M6>=$F$2:$F$4)*(M6<=$G$2:$G$4)*(M7>=$H$2:$H$4)*(M7<=$I$2:$I$4),),0)),"No matches found")

Set Y-axis in FLOT depending on value

How can I set the min and max value of the Y-axis, when it is depending on the highest value, for example 32 (degrees celsius) than I would like a max value of a few degrees higher, with scale linesof 5 degreez
See the documentation on axes costumization for this:
First, try setting the tickSize: 5 option
If flot's automatic tick generation still does not what you want, try also setting the max and min options. For max you could calculate the next multiple of 5 greater than your data maximum (something like max = 5 * (Math.floor(32/5) + 1)).
If all this fails, use the ticks option and give it an array with the specific values you want to have on your axis (something like [0, 5, 10, 15, 20, 25, 30, 35]).

Resources