Python Functions
These are example Python functions you can use as a starting point for developing your own code. Please be aware that these functions are not rigorously tested, so they should NOT be used for production purposes without further validation. They are provided purely as examples with no representation or warranty of any kind.
If there is a function you’d like to see an example of, please email us.
Data
Function | Description |
---|---|
BASIC_CHART | Generates a matplotlib chart from 2D numeric data and returns a PNG image as a base64 string. |
EXCHANGE_RATE | Retrieves the exchange rate from a base currency to a target currency using a public API. |
INTERNET_CSV | Fetches a CSV file from the internet (with CORS proxy) and returns its contents as a 2D list. |
ONEDRIVE_CSV | Retrieves a CSV file from the user’s Microsoft OneDrive App Folder using the Microsoft Graph API and a global variable graphToken for authentication. Returns the CSV contents as a 2D list, suitable for use in Excel. |
SALESFORCE_APIS | Retrieves available Salesforce REST APIs and returns them as a 2D list. |
WORDCLOUD | Generates a word cloud image from provided text data and returns a PNG image as a base64 string. |
Engineering
Fluids
Function | Description |
---|---|
AIRMASS | Calculate the mass of air per square meter in the atmosphere along a given angle using a density profile. |
ARCHIMEDES | Calculate the Archimedes number (Ar) for a fluid and particle. |
ATMOSPHERE_1976 | Calculate standard atmospheric properties at a given altitude using the US Standard Atmosphere 1976 model. |
ATMOSPHERE_NRLMSISE00 | Compute temperature, density, and pressure using the NRLMSISE-00 atmospheric model. |
BEJAN | Compute the Bejan number (length-based or permeability-based) using fluids.core library. |
BOILING | Calculate the Boiling number (Bg), a dimensionless number for boiling heat transfer. |
BOND | Calculate the Bond number (Bo), a dimensionless number comparing gravitational and surface tension forces. |
CAPILLARY | Calculate the Capillary number (Ca) for a fluid system. |
CAVITATION | Calculate the Cavitation number (Ca) for a flowing fluid. |
CONFINEMENT | Calculate the Confinement number (Co) for two-phase flow in a channel. |
DEAN | Calculate the Dean number (De) for flow in a curved pipe or channel. |
DRAG | Calculate the drag coefficient (dimensionless) for an object in a fluid. |
ECKERT | Calculate the Eckert number (Ec) for a given velocity, heat capacity, and temperature difference. |
EULER | Calculate the Euler number (Eu) for a fluid flow. |
FOURIER_HEAT | Calculate the Fourier number for heat transfer. |
FOURIER_MASS | Calculate the Fourier number for mass transfer (Fo). |
FROUDE | Calculate the Froude number (Fr) for a given velocity, length, and gravity. |
Photovoltaics
Function | Description |
---|---|
CALCPARAMS_CEC | Calculate five CEC model parameters for the single diode equation at given irradiance and cell temperature. |
CLEARSKY | Calculate clear sky GHI, DNI, and DHI for a location and time using PVLib. |
I_FROM_V | Calculate the device current at a given device voltage for a PV cell/module using the single diode model. |
IRRADIANCE | Calculate the plane of array irradiance components on a tilted surface using PVLib. |
PVWATTS_DC | Calculate the DC power output of a PV module using the PVWatts DC model. |
SOLARPOSITION | Calculate solar azimuth, elevation, and apparent zenith for given times and location. |
Function | Description |
---|---|
PSYCHROMETRICS | Perform core psychrometric calculations: wet bulb, dew point, humidity ratio, enthalpy. |
STRUCTURAL_FEA | Performs 3D finite element analysis using the Pynite package and returns support reactions. This function is provided as an example only without any representation or warranty of correctness. DO NOT rely on for production use without your own testing and validation. |
Financial
Function | Description |
---|---|
BLACK_SCHOLES | Calculate the Black-Scholes price for a European call or put option. |
GIFI_BAL | Assign GIFI asset codes to balance sheet row labels using an AI model. |
PORTFOLIO_REBALANCER | Tax-efficient rebalancing of assets across Taxable, Roth, and Traditional accounts. |
STOCK_PRICE | Retrieves the latest daily closing price for a given stock symbol using the Alpha Vantage API. |
Math
Integration
Function | Description |
---|---|
DBLQUAD | Compute the double integral of a function over a two-dimensional region. |
QUAD | Numerically integrate a function defined by a table of x, y values over [a, b] using adaptive quadrature. |
SOLVE_IVP | Solve an initial value problem for a system of ODEs of the form dy/dt = A @ y. |
TRAPEZOID | Integrate sampled data using the composite trapezoidal rule. |
Interpolation
Function | Description |
---|---|
BPOLY | Construct a piecewise polynomial in the Bernstein basis and evaluate it at specified points. |
CUBIC_HERMITE_SPLINE | Piecewise cubic interpolation matching values and first derivatives at each point. |
CUBIC_SPLINE | Perform cubic spline interpolation for 1D data. |
GRIDDATA | Interpolate unstructured N-D data using scipy.interpolate.griddata. |
PPOLY | Construct and evaluate a piecewise polynomial in the power basis. |
Linear Algebra
Function | Description |
---|---|
CHOLESKY | Compute the Cholesky decomposition of a Hermitian, positive-definite matrix. |
EXPM | Compute the matrix exponential of a square matrix. |
LSTSQ | Compute the least-squares solution to Ax = B using scipy.linalg.lstsq. |
PINV | Compute the Moore-Penrose pseudoinverse of a matrix using SVD. |
QR | Compute the QR decomposition of a matrix and return either Q or R. |
SVD | Compute the Singular Value Decomposition (SVD) of a matrix. |
Optimization
Function | Description |
---|---|
BASIN_HOPPING | Finds the global minimum of a single-variable function using the basinhopping algorithm. |
HESSIAN_MATRIX | Computes the HESSIAN_MATRIX matrix (second derivatives) of a scalar function with respect to its variables. |
JACOBIAN_MATRIX | Calculate the JACOBIAN_MATRIX matrix of a mathematical expression with respect to specified variables. |
LEAST_SQUARES | Solve a nonlinear least-squares problem by fitting a user-defined model to data. |
LINEAR_ASSIGNMENT | Solves the linear assignment problem (Hungarian algorithm) for a given cost matrix. |
LINEAR_PROG | Solves a linear programming problem using scipy.optimize.linprog. |
MINIMIZE | Minimizes a multivariate function using scipy.optimize.minimize. |
MINIMIZE_SCALAR | Minimizes a scalar function using scipy.optimize.minimize_scalar. |
QUADRATIC_ASSIGNMENT | Solves the quadratic assignment problem (QAP) for given flow and distance matrices. |
ROOT | Solves a square system of nonlinear equations using SciPy’s root-finding capabilities. |
SENSITIVITY_MATRIX | Computes the sensitivity matrix of a model output with respect to parameters using CasADi. |
Statistical
Association Correlation Tests
Function | Description |
---|---|
BARNARD_EXACT | Perform Barnard’s exact test on a 2x2 contingency table. |
BOSCHLOO_EXACT | Perform Boschloo’s exact test on a 2x2 contingency table. |
CHI2_CONTINGENCY | Perform the chi-square test of independence for variables in a contingency table. |
FISHER_EXACT | Perform Fisher’s exact test on a contingency table. |
KENDALLTAU | Calculate Kendall’s tau, a correlation measure for ordinal data. |
PAGE_TREND_TEST | Perform Page’s L trend test for monotonic trends across treatments. |
PEARSONR | Calculate the Pearson correlation coefficient and p-value for two datasets. |
POINTBISERIALR | Calculate a point biserial correlation coefficient and its p-value. |
SIEGELSLOPES | Compute the Siegel repeated medians estimator for robust linear regression. |
SOMERSD | Calculate Somers’ D, an asymmetric measure of ordinal association between two variables. |
SPEARMANR | Calculate a Spearman correlation coefficient with associated p-value. |
THEILSLOPES | Compute the Theil-Sen estimator for a set of points (robust linear regression). |
WEIGHTEDTAU | Compute a weighted version of Kendall’s tau correlation coefficient. |
Clustering
Function | Description |
---|---|
DENDROGRAM | Performs hierarchical (agglomerative) clustering on numeric data and returns a dendrogram as a base64-encoded PNG image or an error message. |
Continuous Distributions
Function | Description |
---|---|
BETA | Generalized Beta distribution function supporting multiple methods. |
CAUCHY | Cauchy distribution function supporting multiple methods. |
CHISQ | Chi-squared distribution function supporting multiple methods. |
EXPON | Exponential distribution function supporting multiple methods. |
F_DIST | Unified interface to the main methods of the F-distribution, including PDF, CDF, inverse CDF, survival function, and distribution statistics. |
LAPLACE | Laplace distribution function supporting multiple methods. |
LOGNORM | Generalized lognormal distribution function supporting multiple methods. |
NORM | Normal (Gaussian) distribution function supporting multiple methods. |
PARETO | Generalized Pareto distribution function supporting multiple methods. |
T_DIST | Student’s t distribution function supporting multiple methods. |
UNIFORM | Uniform distribution function supporting multiple methods. |
WEIBULL_MIN | Weibull minimum distribution function supporting multiple methods. |
Discrete Distributions
Function | Description |
---|---|
BERNOULLI | Calculates properties of a Bernoulli discrete random variable. |
BETABINOM | Compute Beta-binomial distribution values: PMF, CDF, SF, ICDF, ISF, mean, variance, std, or median. |
BETANBINOM | Compute Beta-negative-binomial distribution values: PMF, CDF, SF, ICDF, ISF, mean, variance, std, or median. |
BINOM | Compute Binomial distribution values: PMF, CDF, SF, ICDF, ISF, mean, variance, std, or median. |
BOLTZMANN | Compute Boltzmann distribution values: PMF, CDF, SF, ICDF, ISF, mean, variance, std, or median. |
DLAPLACE | Compute Discrete Laplace distribution values: PMF, CDF, SF, ICDF, ISF, mean, variance, std, or median. |
GEOM | Compute Geometric distribution values: PMF, CDF, SF, ICDF, ISF, mean, variance, std, or median. |
HYPERGEOM | Compute Hypergeometric distribution values: PMF, CDF, SF, ICDF, ISF, mean, variance, std, or median. |
LOGSER | Compute Log-Series distribution values: PMF, CDF, SF, ICDF, ISF, mean, variance, std, or median. |
NBINOM | Compute Negative Binomial distribution values: PMF, CDF, SF, ICDF, ISF, mean, variance, std, or median. |
NHYPERGEOM | Compute Negative Hypergeometric distribution values: PMF, CDF, SF, ICDF, ISF, mean, variance, std, or median. |
PLANCK | Compute Planck distribution values: PMF, CDF, SF, ICDF, ISF, mean, variance, std, or median. |
POISSON_DIST | Compute Poisson distribution values: PMF, CDF, SF, ICDF, ISF, mean, variance, std, or median. |
RANDINT | Compute Uniform discrete distribution values: PMF, CDF, SF, ICDF, ISF, mean, variance, std, or median. |
SKELLAM | Compute Skellam distribution values: PMF, CDF, SF, ICDF, ISF, mean, variance, std, or median. |
YULESIMON | Compute Yule-Simon distribution values: PMF, CDF, SF, ICDF, ISF, mean, variance, std, or median. |
ZIPF | Compute Zipf distribution values: PMF, CDF, SF, ICDF, ISF, mean, variance, std, or median. |
ZIPFIAN | Compute Zipfian distribution values: PMF, CDF, SF, ICDF, ISF, mean, variance, std, or median. |
Frequency Statistics
Function | Description |
---|---|
BINNED_STATISTIC | Computes a binned statistic (mean, sum, median, etc.) for the input data. |
BINNED_STATISTIC_2D | Computes a bidimensional binned statistic (mean, sum, median, etc.) for the input data. |
CUMFREQ | Returns the cumulative frequency histogram for the input data. |
PERCENTILEOFSCORE | Computes the percentile rank of a score relative to the input data. |
RELFREQ | Returns the relative frequency histogram for the input data. |
SCOREATPERCENTILE | Calculates the score at the given percentile of the input data. |
Independent Tests
Function | Description |
---|---|
ALEXANDERGOVERN | Performs the Alexander-Govern test for equality of means across multiple independent samples with possible heterogeneity of variance. |
ANDERSON_KSAMP | Performs the k-sample Anderson-Darling test to determine if samples are drawn from the same population. |
ANSARI | Performs the Ansari-Bradley test for equal scale parameters (non-parametric). |
BRUNNERMUNZEL | Computes the Brunner-Munzel nonparametric test for two independent samples. |
BWS_TEST | Performs the Baumgartner-Weiss-Schindler test on two independent samples. |
CRAMERVONMISES_2SAMP | Performs the two-sample Cramér-von Mises test for goodness of fit between two independent samples. |
DUNNETT | Performs Dunnett’s test for multiple comparisons of means against a control group. |
EPPS_SINGLETON_2SAMP | Computes the Epps-Singleton test statistic and p-value for two samples. |
F_ONEWAY | Performs a one-way ANOVA test for two or more independent samples. |
FLIGNER | Performs the Fligner-Killeen test for equality of variances across multiple samples. |
FRIEDMANCHISQUARE | Computes the Friedman test for repeated samples. |
KRUSKAL | Computes the Kruskal-Wallis H-test for independent samples. |
KS_2SAMP | Performs the two-sample Kolmogorov-Smirnov test for goodness of fit. |
KSTEST | Performs the Kolmogorov-Smirnov test for goodness of fit between two samples or a sample and a reference distribution. |
LEVENE | Performs the Levene test for equality of variances across multiple samples. |
MANNWHITNEYU | Performs the Mann-Whitney U rank test on two independent samples. |
MEDIAN_TEST | Performs Mood’s median test to determine if two or more independent samples come from populations with the same median. |
MOOD | Performs Mood’s two-sample test for scale parameters (non-parametric). |
POISSON_MEANS_TEST | Performs the Poisson means test (E-test) to compare the means of two Poisson distributions. |
RANKSUMS | Computes the Wilcoxon rank-sum statistic and p-value for two independent samples. |
TTEST_IND | Performs the independent two-sample t-test for the means of two groups. |
TTEST_IND_FROM_STATS | Performs a t-test for means of two independent samples using summary statistics. |
TUKEY_HSD | Performs Tukey’s HSD test for equality of means over multiple treatments. |
Miscellaneous
Function | Description |
---|---|
VAL_DISCRETE | Select a value from a list based on a discrete probability distribution. |
Multivariate Distributions
Function | Description |
---|---|
DIRICHLET | Computes the PDF, log-PDF, mean, variance, covariance, entropy, or draws random samples from a Dirichlet distribution. |
DIRICHLET_MULTINOMIAL | Computes the probability mass function, log probability mass function, mean, variance, or covariance of the Dirichlet multinomial distribution. |
MATRIX_NORMAL | Computes the PDF, log-PDF, or draws random samples from a matrix normal distribution. |
MULTINOMIAL | Computes the probability mass function, log-PMF, entropy, covariance, or draws random samples from a multinomial distribution. |
MULTIVARIATE_HYPERGEOM | Computes probability mass function, log-PMF, mean, variance, covariance, or draws random samples from a multivariate hypergeometric distribution. |
MULTIVARIATE_NORMAL | Computes the PDF, CDF, log-PDF, log-CDF, entropy, or draws random samples from a multivariate normal distribution. |
MULTIVARIATE_T | Computes the PDF, CDF, or draws random samples from a multivariate t-distribution. |
ORTHO_GROUP | Draws random samples of orthogonal matrices from the O(N) Haar distribution. |
RANDOM_CORRELATION | Generates a random correlation matrix with specified eigenvalues. |
SPECIAL_ORTHO_GROUP | Draws random samples from the special orthogonal group SO(N), returning orthogonal matrices with determinant +1. |
UNIFORM_DIRECTION | Draws random unit vectors uniformly distributed on the surface of a hypersphere in the specified dimension. |
UNITARY_GROUP | Generates a random unitary matrix of dimension N. |
VONMISES_FISHER | Computes the PDF, log-PDF, entropy, or draws random samples from a von Mises-Fisher distribution on the unit hypersphere. |
WISHART | Computes the PDF, log-PDF, or draws random samples from a Wishart distribution. |
One And Paired Tests
Function | Description |
---|---|
BINOMTEST | Perform a binomial test for the probability of success in a Bernoulli experiment. |
JARQUE_BERA | Perform the Jarque-Bera goodness of fit test for normality. |
KURTOSISTEST | Test whether the kurtosis of a sample is different from that of a normal distribution. |
NORMALTEST | Test whether a sample differs from a normal distribution (omnibus test). |
QUANTILE_TEST | Perform a quantile test and compute a confidence interval of the quantile. |
SHAPIRO | Perform the Shapiro-Wilk test for normality. |
SKEWTEST | Test whether the skewness of a sample is different from that of a normal distribution. |
TTEST_1SAMP | Perform a one-sample t-test for the mean of a group of scores. |
Summary Statistics
Function | Description |
---|---|
DESCRIBE | Compute descriptive statistics of a dataset: nobs, min, max, mean, variance, skewness, kurtosis. |
EXPECTILE | Calculates the expectile of a dataset. |
GMEAN | Compute the geometric mean of the input data, flattening the input and ignoring non-numeric values. |
HMEAN | Calculates the harmonic mean of the input data. |
KURTOSIS | Computes the kurtosis (Fisher or Pearson) of a dataset. |
MODE | Returns the modal (most common) value in the passed array. Flattens the input, ignores non-numeric values, and always returns a single mode (the smallest if multiple). If no mode is found, returns “No mode found”. |
MOMENT | Calculates the nth moment about the mean for a sample. |
PMEAN | Computes the power mean (generalized mean) of the input data for a given power p. |
SKEWNESS | Calculate the skewness of a dataset. |
Text
Function | Description |
---|---|
AI_ASK | Generate a text response using an AI model based on a prompt and optional tabular data. |
AI_CHOICE | Uses AI to select the most appropriate choice from a list of options based on the given context. |
AI_EXTRACT | Uses an AI model to extract specific types of information from unstructured text. |
AI_FILL | Fills missing or incomplete data in a target range by learning patterns from an example range using a large language model. |
AI_FORMAT | Uses an AI model to format text according to a specific structure or pattern. |
AI_LIST | Generate a list of items using an AI model based on a prompt and optional context values. |
AI_TABLE | Uses an AI model to generate a structured table (2D list) based on a prompt, with optional header and source data. |
JINA_READER | Returns web page content in markdown format using Jina. Useful as a starting point for extraction, summarization, etc. |
TEXT_DISTANCE | Calculate text similarity scores between lookup_value(s) and lookup_array items using the specified algorithm. |
VADER_SENTIMENT | Analyze sentiment of text using VADER. |
Last updated on