Derive Columns in the Data Table Cell

It’s easier than ever to clean and wrangle data in the Data Table cell. We’ve introduced the ability to derive a new column using a JavaScript expression. Derived columns make it easy to extract strings, compare columns, concatenate columns, and run calculations on them. The expression used to wrangle data now lives in the table definition itself, keeping your notebooks tidier and helping you move faster through data preparation.

To derive a column, click the new plus icon in the upper-right hand corner of the Data Table cell, and you will be presented with a robust JavaScript expression editor. You can perform basic data manipulation with any column defined in the base table, use the output from other cells, and even use functions defined in other cells.

The JavaScript expression is like a lambda function that passes a parameter object called row. With that object, you can reference any column’s value for each row. Let’s say you have a column called name, where each row contains a person’s full name, like: Bostock, Mike. You can write a simple expression to extract the last name into a new last_name column like this: row["name"].split(', ')[0]. What once took several cells to achieve can now be done completely within the Data Table cell.

Check out the documentation for more details, and let us know if there are ways to make this new feature even better.

6 Likes