String and math expressions
1. String and math expressions
Let's discuss string and math expressions in this video.2. Expression-based transformation
Expression-based transformation allows us to apply custom logic and manipulate data using an expression. This can range from simple arithmetic operations, such as calculating the average score of two subjects, to complex string manipulations.3. Formulating an expression
Let's understand how to formulate an expression. One way is to use operators like plus, minus, and so on. Another way is to use functions that find minimum, maximum, or even join strings. Alternatively, you can specify complex expressions by combining the operators and the functions.4. Expression Node
You have already used the Expression node for conditional statements. Further, it can also be used for formulating expressions. It supplies you with essential functions, math formulas, and various operators. Also, you can specify if this expression will be used to create a new column or replace an existing one.5. String expressions
String expressions are used to perform simple or complex string manipulations. You can formulate the string expression using single or multiple string functions. For example, if you replace the "@" symbol with an "o", formulate the expression using the replace function.6. Popular string functions
The popular string functions are shown in the table. Use the lowercase and uppercase functions to change the case of the text. The capitalize function will change the first letter to uppercase in each word.7. Popular string functions
The join function can concatenate multiple strings using the separator specified.8. Popular string functions
The replace function can replace a pattern in a text, while the find function can find the pattern's location index. Lastly, the length function will return the length of the text in several characters.9. Math expressions
The math expressions are used to perform mathematical transformations. You can formulate the math expression using math operators, functions, and formulas. For example, to find the maximum of two numbers and an arithmetic operation, use the max function and enter the numbers and arithmetic operation as input. The output shows a maximum value of 75.10. Popular math functions
This table shows some popular math functions. Use the max and min functions to find the maximum and minimum values.11. Popular math functions
The functions in the second row can be used to calculate the standard deviation, average, and median of a range of numbers.12. Popular math functions
Use the log and exp function to calculate the logarithm and exponential of a number. Lastly, use the round function to round off decimal numbers to a specified precision.13. Mixed expressions
To perform complex transformations, you can use mixed expressions, which combine string and math functions. For example, given two values, you are asked to add a comment column specifying the minimum value. This is where you can use a mixed expression.14. Mixed expressions
First, you would use a math function to compute the minimum of the two values. Then, the string function converts this value into a string format.15. Mixed expressions
Further, use the join function to concatenate multiple strings using a separator. Specify the separator as a blank space and provide strings to be joined. The output shows the comment column as intended.16. Let's practice!
Now that you have gained expertise in expression-based transformation, let's practice some exercises.Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.