Index
API Reference¶
Plans and running plans¶
- Plans, rule engine and data:
Plan,RuleEngine,RuleData,load_plan,run_plan - Base classes for custom rules
- Exceptions
Rules¶
The rules are available in each backend package: etlrules.backends.pandas, etlrules.backends.polars,
etlrules.backends.dask and etlrules.backends.pyarrow. Use the package of the backend you want to run the plan
with, e.g.:
1 | |
When a plan is loaded from yaml, the backend is chosen when loading it (e.g. load_plan("plan.yml", "polars")).
- Basic rules
- Aggregation rules
- Concatenation rules
- Conditional rules
- Datetime rules
- Fill rules
- Missing values rules
- Join rules
- New column rules
- Numeric rules
- String rules
- Type conversion rules
- Validation rules
- File rules
- Database rules
Backend differences¶
pyarrow¶
The pyarrow backend operates on pyarrow.Tables.
- Expressions (
AddNewColumnRule,IfThenElseRule,FilterRule) support the python operators on columns:+(numbers and strings),-,*,/,%,**, comparisons,&,|,^,~,<<and>>, e.g.df['A'] + df['B'] * 2. Other expressions, e.g. usingand,ororif ... else, are evaluated row by row (slower), withdf['A']being the python value of the column in each row. pandas or polars specific methods (e.g.df['A'].str.upper()) are not supported. - Regular expressions (
ReplaceRulewithregex=True,StrExtractRule) use the RE2 syntax, like the polars backend: look-around assertions and back references are not supported. ReadSQLQueryRuleandWriteSQLTableRuleuse pandas (and SQLAlchemy) to read and write the data.WriteCSVFileRulequotes the column names and the string values.WriteJSONFileRulewrites the rows with python's json module (pyarrow has no JSON writer), which is slower than the other backends for large dataframes.