Often I compare two models using different metrics in the notebook. It would be pretty good if I can just split cell output into 2 columns, fill the first column, then fill the second column.
Now I am calling a function that prints all metrics one by one
check_metrics(model_path)
check_metrics(producion_model_pathes[label])
The output of check metrics looks like output example
Is it possible to split the output into 2 columns, then set as default output the first column, then before calling the second function set the second column as default output? So the output must be looks like the 2 pictures (like above) stacked vertically
Just use the ipywidgets.widgets to create an output widget and set any thing with you want inside:
output1 = widgets.Output()
with output1:
display(check_metrics(model_path))
output2 = widgets.Output()
with output2:
display(check_metrics(model_path))
two_columns = widgets.HBox([output1, output2])
display(two_columns)
Related
Let's say I have text in the following format in Column A imported to another spreadsheet (impossible to add = manually because the data is imported automatically and change):
45+5
45+3
90+2
90+7
Is there any formula that can convert this text into an equation that gives the result of the sum in Column B?
For example:
=ARRAYFORMULA(FUNCTIONTOCONVERTTEXTTOEQUATION(A1:A))
Expected Result:
50
48
92
97
Note: The texts will always be a number after the + sign and then another number.
Given your response to my clarifying question above, let's assume that your raw data is in A2:A. Place the following in the Row-2 cell (e.g., B2) of an otherwise empty column:
=ArrayFormula(IF(A2:A="",,MMULT(IFERROR(TRIM(SPLIT(A2:A,"+"))*1,0),SEQUENCE(COLUMNS(SPLIT(A2:A,"+")),1,1,0))))
MMULT is a powerful yet underused function. I'll include a graphic that explains what it does better than words might:
SPLIT will form the elements of the first matrix, while SEQUENCE will simply create the second matrix consisting of a column of 1's the same length as the number of horizontal elements formed by the SPLIT (which, in your case, will apparently always be 2).
Try, assuming the imported data starts at A1
=arrayformula(sum(value(split(A1,"+"))))
or, in a single formula at the top of the column
=mmult(arrayformula(value(split(A1:A4,"+"))),sequence(2,1,1,0))
I am currently working with Google Forms and want to rearrange the way the responses are being displayed on the "Response Sheet". The only way I can think of doing this is by importing or moving the data to another sheet that would select and transpose certain columns if Column A contains key value.
This is what I'm seeing as part of the input and would like to see as the output if Column A Contains certain text:
Input & Output
Thank you in advance for your help!
O.K.
I rewrite headings a2:e2,
I take whole first five columns without headings e3:e6
I display content of columns A,B,F,G,H for all the rows that have 'A1' in column 1
I take tables built in point 1 and 2 together and sort them by first column
My solution is here:
https://docs.google.com/spreadsheets/d/1n7Ppd8v75mb3qrnJz_Jh_b4HNaj4i56X9wRGnz0l6i8/copy
={A2:E2;
sort({A3:E6;
query(A3:H6,"select A,B,F,G,H where A ='A1'",0)})
}
As you can see I transpose codes into unique column headings so that debits and credits are analysed and summated. Summations are transposed in another sheet to create summary profit/loss account. I need help how to replicate the sum formula in column I to serve any expanded transposed unique codes and whether/how I should use arrayformula for the individual cell output.
EDIT
Actual output looks like this:
My problem is to how to automatically accommodate new entries/codes in the totals row and main body of cells. The data belongs to a residents' committee so I can only show anonymous data as image.
EDIT 2
Actual input is imported from bank records, then coded:
Query is pretty good for the SUM part.
Starting in column I, you can do:
=ArrayFormula(INDEX(QUERY(
0+OFFSET(I4,0,0,ROWS(F6:F),COUNTA(UNIQUE(F4:F))),
"select "&
JOIN(
",",
"sum(Col"&SEQUENCE(COUNTA(UNIQUE(F4:F)))&")"
)
),2))
The 0+ or the VALUE in the second one (they both do the same thing here) transforms the data cells to default to 0 if blank, otherwise the query fails. This also lets us refer to the columns by sequence number, which is what we do in the second argument. We build the query into something that looks like select sum(Col1),sum(Col2),...,sum(ColN). Since this gives us a header by default, we could relabel everything in the query statement, but that gives too much extra code, so the easier thing to do is use INDEX to select the sums.
The EQ part is fairly straightforward to Arrayify. Starting in I4:
=ArrayFormula(
(FILTER(F4:F,F4:F<>"")=FILTER(I2:2,I2:2<>""))*
IF(
Array_constrain(G4:G,COUNTA(FILTER(F4:F,F4:F<>"")),1),
G4:G,
-H4:H
)
)
The FILTERs just filter out the blank cells, and the Array_Constrain sizes the G column to the same size as the filtered F column.
Relative beginner to using formulas in excel/google sheets, and I'm having some trouble figuring out how I can use an array formula to compare cells in different rows but the same column in google sheets (in my case, how I can do =IF(A3=A2,dothis,elsedothis) as an array formula. I'd also be interested if anyone has a different solution other than array formula to autofill formulas in.
The specifics:
I have a list of participants who've done an experiment, and some of them have done it multiple times. With a long list of participants and multiple entries for some participants, it's difficult to see where one participant's info ends and the next begins. So what I want is to alternate the rows in gray and white shading based off of the participant's number (ie. all of 001's entries in gray, all of 002's entries in white, 003's in gray, and so on). To do this, I put in a column on the right using a formula that checks if the participant number in the row above it is the same and, if not, it adds one (I'd like to use this to get a participant count later on). This is what the dataset looks like, and I've included the formula on the right.
A B ... ... X
001 9/1/16 ... ... 1 (1)
001 10/1/16 ... ... 1 (=IF(A3=A2,X2,X2+1))
001 11/1/16 ... ... 1 (=IF(A4=A3,X3,X3+1))
002 9/2/16 ... ... 2 (=IF(A5=A4,X4,X4+1))
002 10/2/16 ... ... 2 (=IF(A6=A5,X5,X5+1))
003 10/5/16 ... ... 3 (=IF(A7=A6,X6,X6+1))
...
All this is working fine and dandy, but the problem is, when I enter a new row, it doesn't automatically fill in the formula, and so the shading doesn't adjust. I suppose I could redrag down the formula every time I enter in new participant info, but that's tedious and I'm not the only one using it, so it's going to get messed up pretty quickly. From what I looked up, arrayformula is what I should be using. But you have to refer to the column as a whole if you use arrayformula. Anyone have any ideas?
Assuming you got the conditional formatting covered, I believe the formula(s) you use can be turned into one single array formula so that the output auto-expands when new rows are added. Example:
={1; ArrayFormula(IF(LEN(A3:A), offset(A2,0,0,ROWS(A3:A),1) + IF(A3:A = offset(A2,0,0,ROWS(A3:A),1), 0, 1),))}
See if that would work for you?
NOTE: the custom formula in conditional formatting used in the spreadsheet is
=AND($X1<>"", ISODD($X1))
One way to achieve the desired result:
To alternate the rows in gray and white shading based on the participant's number do the following:
Under the Format Menu choose conditional formatting
Enteries for the Conditional format rules dialog
In apply to range select the range e.g. A2:A16 (it may include blank cells)
For Format cell if choose Custom formula is
Type =isodd(A2:A16) in the text box below
For Formatting style choose Custom
Choose gray color from the fill button
Finally hit Done
To get a participant count you can use the formula =countunique(A2:A16)
You can do this alltogether without an additional helper column at all, just using conditional formatting:
The custom function to add into the conditional formatting option is this:
=isodd($A:$A)=TRUE
At the end if you still want your participant count, you can use this:
=COUNTA(UNIQUE(A:A))
I am trying to generate a random Cell from specific range:
I need to each cell Row to generate a random selection from a a specific column (range)
below is a picture of my set up and my failed attempts:
You can do this like this:
Add a random number next to your data set using =RAND(). I've used column B, but you can put it wherever you like.
Add this formula to cells C2 to H2
=INDEX($A$2:$A$21,RANK.EQ(INDEX($B$2:$B$21,COLUMN()-2),$B$2:$B$21))
How it works:
RAND() returns a random number in the range [0..1) This is used as a random sort order for your data
Breaking down the formula:
COLUMN()-2 returns a sequential number 1..6 for columns C to H
INDEX($B$2:$B$21, ... ) returns the 1st to 6th number from the random number list
RANK.EQ( ... ,$B$2:$B$21) returns the position of the random number in the sorted random number list, 1..20.
=INDEX($A$2:$A$21, ... ) returns an item from your data set, based on the random rank from above.
Note: This will return a new randon sample each time Excel recalculates.
The only way to make a random selection that does not repeat is to make an array of integers, than randomize it, and than take out one by one.
For example you start with:
1 2 3 4 5 6 7
you randomize it (swap elements randomly)
2 4 5 1 7 3 6
than you take elements out one by one. (keep an index of how much elements you used in some cell)
Ok here is one trick, add another column with random numbers, than select both random column and range column and click the sort button (picture is from libreoffice but there is a similar button in excel) This will randomize your range column. Than you simply assign values to "w-1" : "w-6" like this =B2, =B3, =B4, =B5, =B6, =B7
I tried this and it works like you wanted, the only problem is it will shuffle values in your range column.