{"id":2328,"library":"triad","title":"Triad","description":"Triad is a Python utility library primarily designed to support Fugue projects, offering a collection of common Python utilities for data processing, schema management, and function dispatching. It is currently at version 1.0.2 and maintains an active release cadence, often aligning with Fugue updates or addressing compatibility with key data science libraries like Pandas and PyArrow.","status":"active","version":"1.0.2","language":"en","source_language":"en","source_url":"https://github.com/fugue-project/triad","tags":["utilities","fugue","data-processing","pandas","pyarrow","schema-validation"],"install":[{"cmd":"pip install triad","lang":"bash","label":"Install core package"},{"cmd":"pip install triad[ciso8601]","lang":"bash","label":"Install with optional fast datetime parsing"}],"dependencies":[{"reason":"Required Python version.","package":"python","version":">=3.9"},{"reason":"Core functionality relies heavily on Pandas DataFrames and their utilities.","package":"pandas","optional":false},{"reason":"Integrated for flexible file system operations.","package":"fsspec","optional":false},{"reason":"Used for schema handling and data type conversions.","package":"pyarrow","optional":false},{"reason":"Optional dependency for faster datetime string parsing.","package":"ciso8601","optional":true}],"imports":[{"symbol":"FunctionWrapper","correct":"from triad.collections import FunctionWrapper"},{"symbol":"Schema","correct":"from triad.collections import Schema"},{"symbol":"run_at_def","correct":"from triad.utils.dispatcher import run_at_def"},{"symbol":"assertion","correct":"from triad.utils import assertion"}],"quickstart":{"code":"import pandas as pd\nfrom triad.collections import FunctionWrapper, Schema\n\n# Example of FunctionWrapper for input/output validation\n@FunctionWrapper(\n    params_re=\"(pa:pd.DataFrame,pb:pd.DataFrame)(.*)\",\n    return_re=\"(res:pd.DataFrame)\"\n)\ndef process_dataframes(pa: pd.DataFrame, pb: pd.DataFrame, *args) -> pd.DataFrame:\n    \"\"\"A dummy function to demonstrate FunctionWrapper validation.\"\"\"\n    print(f\"[FunctionWrapper] Received dataframes with columns: {pa.columns.tolist()}, {pb.columns.tolist()}\")\n    print(f\"[FunctionWrapper] Received other args: {args}\")\n    return pd.DataFrame({\"sum_rows\": [len(pa) + len(pb)]})\n\n# Create some dummy dataframes\ndf1 = pd.DataFrame({\"col1\": [1, 2], \"col2\": [\"a\", \"b\"]})\ndf2 = pd.DataFrame({\"colA\": [3, 4, 5], \"colB\": [\"c\", \"d\", \"e\"]})\n\n# Call the wrapped function\nresult = process_dataframes(df1, df2, \"extra_param\", 42)\nprint(f\"\\nFunction result:\\n{result}\")\n\n# Example of Schema usage\ns = Schema(\"id:int,name:str,value:double\")\nprint(f\"\\nCreated Schema: {s.as_str}\")\n\n# Convert a dictionary to a Pandas DataFrame conforming to the schema\ndata = {\"id\": [101, 102], \"name\": [\"Alice\", \"Bob\"], \"value\": [1.1, 2.2]}\ndf_from_schema = s.as_pandas_df(data)\nprint(f\"\\nDataFrame from Schema:\\n{df_from_schema}\")","lang":"python","description":"This quickstart demonstrates two core utilities of Triad: `FunctionWrapper` for validating function inputs and outputs based on regex patterns of types, and `Schema` for defining and managing data schemas, including conversions to/from Pandas DataFrames."},"warnings":[{"fix":"Migrate any usage of `triad.fs` utilities to direct `fsspec` or other file system library calls, or adapt to the new I/O utilities introduced after the change.","message":"The `fs` module and its associated functionality were removed in version 1.0.0. Projects relying on `triad`'s file system abstractions will need to refactor their code.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always check `triad`'s release notes for specific Pandas version compatibility before upgrading either library. Pinning Pandas versions in `requirements.txt` is recommended for production environments. Ensure your `triad` version is compatible with your `pandas` version, or upgrade `triad` to the latest for broader compatibility.","message":"Triad frequently updates to maintain compatibility with new Pandas versions (e.g., Pandas 2.0, 2.2, 3.0). This can lead to unexpected behavior or errors if `triad` and `pandas` versions are not carefully aligned.","severity":"gotcha","affected_versions":"<1.0.2"},{"fix":"For optimal performance with datetime operations, install `triad` with the `ciso8601` extra: `pip install triad[ciso8601]`.","message":"The `ciso8601` package is an optional dependency for faster datetime parsing. If not installed, `triad` will fall back to slower Python-native parsing, which can impact performance, especially on Windows where `ciso8601` historically had specific soft-dependency behavior.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}