How to insert variables into a text cell using google colab - python-3.x

I would like to insert a python variable into a text cell, in google colab.
For example, if a=10, I would like to insert the a into a text cell and render the value.
So in the text cell (using Jupyter Notebook with nbextensions) I would like to write the following in the text cell:
There will be {{ a }} pieces of fruit at the reception.
It should show up as:
There will be 10 pieces of fruit at the reception.
The markdown cheatsheets and explanations do not say how to achieve this. Is this possible currently?

It's not possible to change 'input cell' (either code or markdown) programmatically. You can change only the output cells. Input cells always require manually change. (even %load doesn't work)

Related

Databricks notebook how to add a title to a cell

How to add title to the cell itself like this (The tile and the code are in the same command cell):
Instead of putting it in a separate cell like this (The tile and the code are in different command cells):
Maybe you want which will give you

Excel - Search a cell for text strings from an array and display matched strings

I have a large-ish spreadsheet of about 1400 rows. One of the columns in that row has been populated from a free-flow text and contains details about numerous items people are requesting. There's no consistency about what's in the text box though.
Image 1 has an example of what the data looks like. C2 is the cell with the data in is. D2 is where I want to extract the list of things from C2 to. If an item appears multiple times I only want it to show once.
Example image of data
The list where the things I want to look for is on a separate sheet (Example of list array) and the list is defined by the range name "items" and runs from A2:A95.
I'm using Excel365 (despite the example screenshots) and have been trying various solutions from here on SO and various other Excel help pages but can't find anything that will work how I've got things setup. I've nothing against using VBA if that's the only way to do it, but would prefer a simpler solution if possible.
Thanks in advance.
I created a Named Range for your reference list so in my formula ThingsToLookUp is referencing the range A2:A9 in my sample file below.
=TEXTJOIN(", ",TRUE,IF(ISERROR(SEARCH(ThingsToLookUp,C2)),"",ThingsToLookUp))
Note that you will stumble on some edge cases here with SEARCH. For instance, if the string has Crossbow you will always output Crossbow and Bow since the later is a substring of the first. Less important but this solution also outputs the items in the order as they appear on the reference list, not as they appear in the input string.

Excel: Search rows for keywords and populate cells with those keywords

This question will be almost exactly like the question below, but I need a slight change to it for my application and I can't quite figure it out:
excel: how can I identify rows containing text keywords taken from a list of keywords
If a row of several text filled cells contains any keyword from a list of keywords, I would like to add that keyword to the end of the row. Each row will be the same number of cells, but some can be blank and they are not necessarily all the same data type, some could be numbers or dates etc. Even more, I would like to add every keyword that appears in the row of text to the end of the row in separate cells.
Relating to the example post that almost answers my question, I am using the more complicated formula for multiple matches, but in that example they only have one column of data they are looking for keywords in. I have several that would be formatted similar to their column A. I tried changing some of the ranges around with no luck specifically where the formula posted has: IF(COUNTIF($A1,"*"&$B$1:$B$10&"*") I changed $A1, to $A1:$D1 with no luck.
The problem showed up because I have several large spreadsheets of text based data about failure modes of different tools and I would like to categorize them in a little more of a controlled way than free form text in every cell and assigning controlled keywords that apply seems like a decent way to do this.
Example case
Expected result
The keyword list shown in Example Case is not shown in the Expected result. The range of keywords is K2:K6
Another feature that would be useful is if I could assign additional words that when found would trigger one of the key words. For example if the key word is "Gear wear" then "Gear wear" would trigger a hit but "stripped gears" would also trigger a hit. I would imagine the keyword list would be set up as a 2D Range with the first column being the actual key word and the cells to the right of each row would be additional words that trigger the key word. I suspect I am getting to the point where I would need to create a VBA macro to do this. If there is a way to accomplish this without writing code it would make it more repeatable on other user's computers.
Enter following formula in Cell F1 then drag/copy across and down as required.
=IFERROR(INDEX($K$2:$K$6,SMALL(IF(COUNTIF($A1:$D1,"*"&$K$2:$K$6&"*"),ROW($K$2:$K$6)-ROW($A$1)),COLUMNS($A1:A1))),"")
This is an array formula so commit it by pressing Ctrl+Shift+Enter
See the image for reference
This formula is derived from the link mentioned in your question.

How to recreate this type of map in Excel?

Above is the map I want to recreate in Excel. My data are listed below:
Region People Percentage
South 3,919,780 32.50%
Midwest 2,533,333 21.01%
Northeast 2,686,860 22.28%
West 2,919,833 24.21%
Can anyone please advise on how to start this in Excel? Or, will I need to use different software? I'm using Excel 2007 on Windows, for reference.
You can do that in Excel, and it won't be too hard really. I assume that you already have the map you show in an image form?
You could import the map into Excel, then insert text boxes over the different regions you have. Then, instead of typing INTO the text box, you can use a formula to refer to a cell with a value.
Say your "South" Percentage (32.50) is in Sheet2, Cell C3. Just use the formula =Sheet2!C3 as the Text Box contents, and you'll see the text box update itself as C3 changes.
Screenshot
So instead of typing =Sheet2!C3 or whatever into the text box itself, do so in the formula bar.
If you need to add the map, I've done something like this in the past, so just Google around for SVG or other images, and use that as your background to put the input boxes over.

Using LOOKUP with a string of more than 255 characters

In Excel 2010 I'm using =LOOKUP to place text in a cell dependent on the value of the cell being looked up. Short text strings work, but longer text strings cause a formula error. Here's the formula:
=LOOKUP(B58,{0,0;40,"TextA";100,"TextB";125,"TextC";145,"TextD";165,"TextE";200,""})
which works correctly and displays TextA or TextB etc. depending on the value in B58. However I want the LOOKUP to show a lot of text such as:
=LOOKUP(B58,{0,0;40,"Lots of text in here";100,"TextB";125,"TextC";145,"TextD";165,"TextE";200,""})
where the "Lots of text in here" is 432 characters, no punctuation but includes spaces.
So I don't really know, I'm assuming character limit.
Is there a way to adjust that LOOKUP so if the value is "whatever" it'll return text stored in a cell elsewhere on the worksheet?
It is usually easier to place the lookup table itself in an area of cells in the sheet, or another worksheet.
Then your lookup formula can reference cells in the worksheet without the need for a large formula to be typed out.
See here for more info, specifically example 1.
It gives better control over your lookup list, and you can easily change this when required.
There is a restriction on the size of the formula text set at 8192 characters, as specified in the table here.
Hope this helps.
Excel does have a warning (and, for a change, helpful advice!):
Instead of "Lots of text in here" something like "Lots of text"&" in here" with the & around the half-way mark should serve.

Resources