.apply() and passing callables
Some pandas functions, like df.apply(f), support an arbitrary function as a parameter.
Most of the time, Terality will support these functions without any change.
In a few situations, Terality won't be able to transfer the arbitrary function defined in your code to the Terality servers. This page lists which scenarios are supported, and which are currently not.

Supported cases

Terality accepts functions (and lambdas) that depend on known modules:
  • functions from the Python 3.8 standard library:
1
from math import floor
2
3
# supported, function from the standard library
4
df.apply(floor)
Copied!
  • functions from pandas
  • functions from numpy:
1
import numpy as np
2
3
# supported, numpy function
4
df.apply(np.float64)
Copied!
  • functions (or lambdas) defined by the user in the current module:
1
def my_function_1(x):
2
return x**2
3
4
def my_function_2(x):
5
return 1 / (1 + my_function_1(x))
6
7
# supported, functions are all defined in the same module
8
df.apply(my_function_1)
9
df.apply(my_function_2)
10
11
# supported, lambdas are ok too
12
df.apply(lambda x: 1 / (1 + x^2))
Copied!
  • and any combination of the supported cases mentioned previously

Unsupported cases

Terality currently does not support functions:
  • using third party dependencies other than numpy and pandas
  • defined in other modules:
1
from my_custom_module import my_custom_function
2
3
# Terality can not import such a function
4
df.apply(my_custom_function)
Copied!
  • referencing a Terality structure:
1
s = te.Series([0, 1, 2])
2
s2 = te.Series(["a", "b", "c"])
3
4
# unsupported
5
s.apply(lambda x: s2.iloc[x])
Copied!
Additionally, functions with side effects (such as accessing the network or writing to disk) are not supported. They may return the correct result, raise an error, or silently return an incorrect result.