classmethod ExtensionDtype.construct_from_string(string) [source]
Attempt to construct this type from a string.
| Parameters: |
|
|---|---|
| Returns: |
|
| Raises: |
TypeError If a class cannot be constructed from this ‘string’. |
If the extension dtype can be constructed without any arguments, the following may be an adequate implementation.
>>> @classmethod
... def construct_from_string(cls, string)
... if string == cls.name:
... return cls()
... else:
... raise TypeError("Cannot construct a '{}' from "
... "'{}'".format(cls, string))
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
http://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.api.extensions.ExtensionDtype.construct_from_string.html