Differences with the pandas API
This page documents the few differences between Terality and the pandas API.

Data mutability and ownership

Terality always returns copies and never shares data between two DataFrame or Series. This makes Terality more predictable than pandas. More details on this dedicated page:

Passing functions as parameters

Some pandas functions support an arbitrary function as a parameter (for instance, the key parameter of pd.DataFrame.sort_values). Terality only accepts functions that depend on known modules:
    any module from the Python 3.8 standard library
    pandas
    numpy
    the current module
Terality supports both named functions and lambda functions.
Examples:
1
import terality as pd
2
df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
3
4
# supported, no dependencies:
5
df.sort_values(by='A', key=lambda x: -x)
6
7
# supported, only depends on numpy, which belongs to the list of known modules:
8
import numpy as np
9
df.sort_values(by='A', key=lambda x: np.float64(x))
10
11
12
def example_1(x):
13
return np.float64(x)
14
15
def example_2(x):
16
return x + example_1(x)
17
18
# example_2 only depends on functions defined in the same module (example_1)
19
# and functions in known modules (np.float64)
20
df.sort_values(by='A', key=example_2)
21
22
# not supported, depends on a module that's not available in Terality
23
from mycustommodule import custom_function
24
df.sort_values(by='A', key=lambda x: custom_function(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.
Last modified 1mo ago