@classmethod<EOL><INDENT>def construct_from_string(cls, string):<DEDENT>
msg = "<STR_LIT>".format(string)<EOL>if string.startswith("<STR_LIT>"):<EOL><INDENT>try:<EOL><INDENT>sub_type, has_fill_value = cls._parse_subtype(string)<EOL>result = SparseDtype(sub_type)<EOL><DEDENT>except Exception:<EOL><INDENT>raise TypeError(msg)<EOL><DEDENT>else:<EOL><INDENT>msg = ("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL>if has_fill_value and str(result) != string:<EOL><INDENT>raise TypeError(msg.format(string))<EOL><DEDENT>return result<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise TypeError(msg)<EOL><DEDENT>
Construct a SparseDtype from a string form.

Parameters
----------
string : str
    Can take the following forms.

    string           dtype
    ================ ============================
    'int'            SparseDtype[np.int64, 0]
    'Sparse'         SparseDtype[np.float64, nan]
    'Sparse[int]'    SparseDtype[np.int64, 0]
    'Sparse[int, 0]' SparseDtype[np.int64, 0]
    ================ ============================

    It is not possible to specify non-default fill values
    with a string. An argument like ``'Sparse[int, 1]'``
    will raise a ``TypeError`` because the default fill value
    for integers is 0.

Returns
-------
SparseDtype