Skip to content

Applying functions

Damien Farrell edited this page Jan 4, 2016 · 4 revisions

Unlike a spreadsheet there are no cell based formulas. Rather functions are applied to columns over all rows. This can be done in several ways, either by evaluating a simple text expression or by applying a supported set of pre-defined formulas. (Since these features are somewhat experimental some functionality may change).

Evaluating arithmetic expressions

Access by pressing the 'calculate' button on the toolbar which creates a panel for entering expressions. This uses pd.eval and requires the numexpr library which should be present by default. The same as for filtering, a string is entered like a formula and if it can be parsed a new column is created. For example entering 'x = a + b' will create a new column x that is the sum of a and b.

Examples:

x = a+b  #sum a and b
x = a*a  #a squared
x = sin(a)
x = sqrt(a+b)/log(c)

Supported functions in expressions:

  • sin, cos, tan, arcsin, arccos, arctan, sinh, cosh, tanh
  • log, log10, exp

Predefined functions using dialogs

Accessed by right-clicking on the column header and choosing either of two options:

Apply Function

This allows functions to be applied row wise such as value_counts or shift. Thus a new column with different numbers of rows may be created. A dialog is shown where functions can be selected with the option to name the new column etc. When the function is chosen another dialog pops up that allows you to enter the parameters. Only a subset of functions are present that have been tested.

Apply Function col-wise

Functions to be applied column wise, such as the mean of multiple columns etc. Will create new columns in the same table.

Supported functions:

  • mean
  • std
  • max
  • min
  • round
  • floor
  • ceil
  • trunc
  • sum
  • subtract
  • divide
  • mod
  • remainder
  • convolve
  • negative
  • sign
  • power
  • degrees
  • radians