pandas.SparseDtype.construct_from_string

classmethod SparseDtype.construct_from_string(string) [source]

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

© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.24.2/reference/api/pandas.SparseDtype.construct_from_string.html