Create new columns with conditions
Our example visualised. Note that each row in your columns will go through this decision tree.
Our example in Less
Syntax | Meaning | Example | Condition |
---|---|---|---|
== | Equals | [NumberColumn] == 1 | All rows where NumberColumn is equal to 1 |
!= | Does not equal | [TextColumn] != "Sales" | All rows where TextColumn does not equals Sales |
< | Less than | [NumberColumn] < 20 | All rows where NumberColumn is less than 20 |
> | Greater than | [NumberColumn] > 100 | All rows where NumberColumn is larger than 100 |
<= | Less than or equal to | [NumberColumn] <= 0.5 | All rows where NumberColumn is less than or equal to 0.5 |
>= | Larger than or equal to | [NumberColumn] >= 150 | All rows where NumberColumn is larger than or equal to 150 |
.contains() | A text column contains a certain value | [TextColumn].contains("Hello") | All rows where TextColumn contains “Hello” - for instance “Hello world” |
.startswith() | A text column that begins with a certain value | [TextColumn].startswith("Hello") | All rows where TextColumn starts with “Hello” - for instance “Hello world” |
.endswith() | A text column that ends with a certain value | [TextColumn].endswith("world") | All rows where TextColumn ends with “world” - for instance “Hello world” |
.isna() | Null | [NumberColumn].isna() | All rows where NumberColumn is null |
.isnull() | Null | [TextColumn].isnull() | All rows where TextColumn is null |
& | AND -> Used to pair multiple statements together | ([NumberColumn]==1) & ([TextColumn=="Client") | All rows where TextColumn is equal to “Client” AND NumberColumn is equal to 1. Note that both conditions must be fulfilled for the statement to be true |
| | OR -> Used to determine if any conditions in a test is true | ([NumberColumn]==1) & (([TextColumn=="Client") | ([TextColumn]=="Customer")) | All rows where TextColumn is equal to “Client” OR “Customer” AND NumberColumn is equal to 1. Note that just one of the OR conditions must be fulfilled for the statement to be true |
.contains()
, .startswith()
and .endswith()
is case sensitive[TextColumn=="Client" & [TextColumn]=="Customer"
But this does work: ([TextColumn=="Client") | ([TextColumn]=="Customer")
You can pass as many AND and OR clauses into a statement as you want as long as you remember parentheses.Hello World
and your first condition is IF .startwith("Hello") THEN "Something"
and your second condition is IF .endswith("World") THEN "SomethingElse"
then your output will rely on the first true condition which will lead to an output of Something
Input Column Name
Add Your Condition(s)
Add Else Clause
Custom Shipping Fee
Hospital Patient Triage
Expense Category Flagging