Visions Data Type Inference

0.8.1 · active · verified Sat Apr 11

Visions is a Python library for declarative data type inference and validation. It allows users to define custom data types and their hierarchical relationships, then detect and cast these types within data structures like Pandas Series. The current version is 0.8.1, and it maintains a moderate release cadence, primarily focusing on compatibility fixes and API improvements.

Warnings

Install

Imports

Quickstart

This example demonstrates how to use `visions` to detect the data type of a Pandas Series and then cast it to a different specified type using a standard typeset.

import pandas as pd
from visions import detect_type, cast_to_detected_type
from visions.types import Integer, String
from visions.typesets import StandardTypeset

# Example data
data = pd.Series([1, 2, 3, 4, 5])

# Initialize a typeset
typeset = StandardTypeset()

# Detect the initial type of the data
initial_type = detect_type(data, typeset)
print(f"Detected initial type: {initial_type.__class__.__name__}")

# Cast the data to a different type (e.g., String)
casted_data = cast_to_detected_type(data, String, typeset)
casted_type = detect_type(casted_data, typeset)
print(f"Casted data type: {casted_type.__class__.__name__}")
print(f"Casted data content: {casted_data.to_list()}")

view raw JSON →