Detail: Frame: Accessor Type Clinic

Overview: Frame: Accessor Type Clinic

Frame.via_type_clinic.to_hint
Frame.via_type_clinic
TypeClinic.to_hint()[source]

Return the type hint (the type and/or generic aliases necessary) to represent the object given at initialization.

>>> f = sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), index=sf.IndexHierarchy.from_product((0, 1), ('p', 'q')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x')
>>> f
<Frame: x>
<Index>                a       b      c               <<U1>
<IndexHierarchy>
0                p     10      False  1517-01-01
0                q     2       True   1517-04-01
1                p     8       True   1517-12-31
1                q     3       False  1517-06-30
<int64>          <<U1> <int64> <bool> <datetime64[D]>
>>> f.via_type_clinic.to_hint()
static_frame.core.frame.Frame[static_frame.core.index_hierarchy.IndexHierarchy[static_frame.core.index.Index[numpy.int64], static_frame.core.index.Index[numpy.str_]], static_frame.core.index.Index[numpy.str_], numpy.int64, numpy.bool_, numpy.datetime64]
Frame.via_type_clinic.check(hint, *, fail_fast)
Frame.via_type_clinic
TypeClinic.check(hint, /, *, fail_fast=False)[source]

Given a hint (a type and/or generic alias), raise a ClinicError exception describing the result of the check if an error is found.

Parameters:

fail_fast – If True, return on first failure. If False, all failures are discovered and reported.

>>> f = sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), index=sf.IndexHierarchy.from_product((0, 1), ('p', 'q')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x')
>>> f
<Frame: x>
<Index>                a       b      c               <<U1>
<IndexHierarchy>
0                p     10      False  1517-01-01
0                q     2       True   1517-04-01
1                p     8       True   1517-12-31
1                q     3       False  1517-06-30
<int64>          <<U1> <int64> <bool> <datetime64[D]>
>>> f.via_type_clinic.check(sf.Frame[sf.IndexHierarchy[sf.Index[np.int64], sf.Index[np.str_]], sf.Index[np.int64], np.int64, np.bool_, np.str_])
ClinicError('\nIn Frame[IndexHierarchy[Index[int64], Index[str_]], Index[int64], int64, bool_, str_]\n└── Expected str_, provided datetime64 invalid\nIn Frame[IndexHierarchy[Index[int64], Index[str_]], Index[int64], int64, bool_, str_]\n└── Index[int64]\n    └── Expected int64, provided str_ invalid')
Frame.via_type_clinic.warn(hint, *, fail_fast, category)
Frame.via_type_clinic
TypeClinic.warn(hint, /, *, fail_fast=False, category=<class 'UserWarning'>)[source]

Given a hint (a type and/or generic alias), issue a warning describing the result of the check if an error is found.

Parameters:
  • fail_fast – If True, return on first failure. If False, all failures are discovered and reported.

  • category – The Warning subclass to be used for issueing the warning.

Frame.via_type_clinic.__call__(hint, *, fail_fast)
Frame.via_type_clinic
TypeClinic.__call__(hint, /, *, fail_fast=False)[source]

Given a hint (a type and/or generic alias), return a ClinicResult object describing the result of the check.

Parameters:

fail_fast – If True, return on first failure. If False, all failures are discovered and reported.

>>> f = sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), index=sf.IndexHierarchy.from_product((0, 1), ('p', 'q')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x')
>>> f
<Frame: x>
<Index>                a       b      c               <<U1>
<IndexHierarchy>
0                p     10      False  1517-01-01
0                q     2       True   1517-04-01
1                p     8       True   1517-12-31
1                q     3       False  1517-06-30
<int64>          <<U1> <int64> <bool> <datetime64[D]>
>>> cr = f.via_type_clinic(sf.Frame[sf.IndexHierarchy[sf.Index[np.int64], sf.Index[np.str_]], sf.Index[np.int64], np.int64, np.bool_, np.str_])
>>> cr
<ClinicResult: 2 errors>
>>> cr.validated
False
>>> cr.to_str()

In Frame[IndexHierarchy[Index[int64], Index[str_]], Index[int64], int64, bool_, str_]
└── Expected str_, provided datetime64 invalid
In Frame[IndexHierarchy[Index[int64], Index[str_]], Index[int64], int64, bool_, str_]
└── Index[int64]
    └── Expected int64, provided str_ invalid
Frame.via_type_clinic.__repr__
Frame.via_type_clinic
TypeClinic.__repr__()[source]

Return a compact string representation of the type hint (the type and/or generic aliases necessary) to represent the object given at initialization.

>>> f = sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), index=sf.IndexHierarchy.from_product((0, 1), ('p', 'q')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x')
>>> f
<Frame: x>
<Index>                a       b      c               <<U1>
<IndexHierarchy>
0                p     10      False  1517-01-01
0                q     2       True   1517-04-01
1                p     8       True   1517-12-31
1                q     3       False  1517-06-30
<int64>          <<U1> <int64> <bool> <datetime64[D]>
>>> f.via_type_clinic
Frame[IndexHierarchy[Index[int64], Index[str_]], Index[str_], int64, bool_, datetime64]

Frame: Constructor | Exporter | Attribute | Method | Dictionary-Like | Display | Assignment | Selector | Iterator | Operator Binary | Operator Unary | Accessor Values | Accessor Datetime | Accessor String | Accessor Transpose | Accessor Fill Value | Accessor Regular Expression | Accessor Hashlib | Accessor Type Clinic | Accessor Reduce