def test_type_detect_series(): datetime_series = pd.Series([ datetime.datetime(2010, 1, 1), datetime.datetime(2010, 8, 2), datetime.datetime(2011, 2, 1), np.datetime64("NaT"), ]) typeset = StandardSet() detected_type = detect_series_type(datetime_series, typeset) assert detected_type == DateTime
def generate_typeset_plots() -> None: typesets_dir = Path("typesets/") typesets_dir.mkdir(exist_ok=True) # Initialize typeset for name, tsc in [ ("typeset_complete", CompleteSet()), ("typeset_geometry", GeometrySet()), ("typeset_standard", StandardSet()), ]: # Write graph to dot tsc.output_graph(typesets_dir / "{name}.dot".format(name=name)) # Plot the graph (svg) tsc.output_graph(typesets_dir / "{name}.svg".format(name=name)) tsc.output_graph(typesets_dir / "{name}_base.svg".format(name=name), base_only=True) # Plot the graph (png) tsc.output_graph(typesets_dir / "{name}.png".format(name=name), dpi=150)
import pandas as pd from visions.functional import detect_series_type from visions.typesets import StandardSet from visions.types import Categorical, Boolean from examples.data_analysis.categorical import Category ts = StandardSet() ts -= Boolean ts -= Categorical ts += Category s1 = pd.Series(["A", "B", "C"] * 1000, dtype="category") print(s1 in Category) print(detect_series_type(s1, ts)) s2 = pd.Series([True, False] * 1000) print(s2 in Category) print(detect_series_type(s2, ts))
def test_type_cast_detect_series(): string_series = pd.Series(["(12.0+10.0j)", "(-4.0+6.2j)", "(8.0+2.0j)"]) typeset = StandardSet() new_series = cast_to_detected(string_series, typeset) assert new_series.iloc[1] == "(-4.0+6.2j)"
def test_type_cast_infer_series(): string_series = pd.Series(["(12.0+10.0j)", "(-4.0+6.2j)", "(8.0+2.0j)"]) typeset = StandardSet() new_series = cast_to_inferred(string_series, typeset) assert new_series.iloc[1].real == -4.0
def test_type_inference_series(): string_series = pd.Series(["(12.0+10.0j)", "(-4.0+6.2j)", "(8.0+2.0j)"]) typeset = StandardSet() detected_type = infer_type(string_series, typeset) assert detected_type == Complex
from pathlib import Path from visions.typesets import CompleteSet, StandardSet, GeometrySet # Windows Note # Tip for Python3/64-bit compatible version of pygraphviz # https://github.com/CristiFati/Prebuilt-Binaries/raw/master/Windows/PyGraphviz/pygraphviz-1.5-cp37-cp37m-win_amd64.whl typesets_dir = Path("typesets/") typesets_dir.mkdir(exist_ok=True) # Initialize typeset for name, tsc in [ ("typeset_complete", CompleteSet()), ("typeset_geometry", GeometrySet()), ("typeset_standard", StandardSet()), ]: # Write graph to dot tsc.output_graph(typesets_dir / "{name}.dot".format(name=name)) # Plot the graph (svg) tsc.output_graph(typesets_dir / "{name}.svg".format(name=name)) tsc.output_graph(typesets_dir / "{name}_base.svg".format(name=name), base_only=True) # Plot the graph (png) tsc.output_graph(typesets_dir / "{name}.png".format(name=name), dpi=150)