This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// trip leading chars | |
lstrip = LAMBDA(text, char, | |
BYROW(text, | |
LAMBDA(t, IF(LEFT(t)=char, lstrip(MID(t,2,len(t)),char), t)) | |
) | |
); | |
// trim trailing chars | |
rstrip = LAMBDA(text, char, | |
BYROW(text, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There is a feature of Excel called Python in Excel. It allows you to create a "Python cell" in an Excel spreadsheet. In a Python cell, you can execute Python code. | |
For each session, these imports are run automatically: | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import statsmodels as sm | |
import seaborn as sns | |
import excel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sympy import integrate | |
def integration_image(symbol: str, expr: str): | |
"""Integrates expr with respect to symbol | |
integration_image(symbol='x', expr='exp(x)*sin(x) + exp(x)*cos(x)') | |
Dependencies: 'from sympy import integrate' must be run before use | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
solver=LAMBDA(grid, | |
LET( | |
numbers, SEQUENCE(9), | |
numgrid, SEQUENCE(9,9,0), | |
vgrid, TOCOL(grid*1), | |
pos, XMATCH(0,vgrid)-1, | |
IF( | |
ISNA(pos), grid, | |
LET( | |
i,INT(pos/9), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Provides a FORMULATEXT capability for Python cells | |
pythonCell: A reference to a Python cell | |
[asArray]: A TRUE/FALSE value indicating whether | |
or not to spill the results of the formula | |
default is TRUE | |
*/ | |
FORMULATEXT.PY = LAMBDA(pythonCell,[asArray], | |
LET( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chart.Quadrants = LAMBDA(seriesData, | |
LET( | |
// The first column (x values) | |
x, TAKE(seriesData, , 1), | |
// The second column (y values) | |
y, TAKE(seriesData, , -1), | |
xMax, MAX(x), | |
yMax, MAX(y), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FILLDOWN = LAMBDA(arr, SCAN(,arr,LAMBDA(a,b,IF(b<>"",b,a)))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(Source as table, header_condition as function) as any => | |
let | |
// two row header | |
hh = Table.SelectRows(Source, header_condition) , | |
// list of new column headers | |
h = List.Accumulate( | |
Table.ToColumns(hh), | |
{}, | |
(a,b) => List.Combine({a,{Text.Combine(b," ")}}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let fn = | |
( | |
Table as table, | |
MembershipFunction as function, | |
Substring as text, | |
optional IgnoreCase as nullable logical | |
) as list => | |
let | |
// Handle omitted IgnoreCase with default false | |
_IgnoreCase = if IgnoreCase = null then false else IgnoreCase, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(Data as table, ComparisonColumns as list, ReplacementFunction as function) as table => | |
let | |
AddRecords = Table.AddColumn(Data, "Record",each _), | |
AddSortedComparisonValues = Table.AddColumn( | |
AddRecords, | |
"SortedComparisonValues", | |
each List.Sort( | |
Record.FieldValues( | |
Record.SelectFields(_, ComparisonColumns) |