dtoolkit.accessor.series.getattr#

dtoolkit.accessor.series.getattr(s: Series, name: str, /, *args, **kwargs) Series[source]#

Return the value of the named attribute of Series element.

The back core logical is getattr().

Read more in the User Guide.

Parameters
namestr

The name of one of the Series element’s attributes. If the named attribute does not exist, None is returned.

*args, **kwargs

The arguments of the function type attribute.

Returns
Series

See also

getattr

Examples

>>> import dtoolkit
>>> import pandas as pd
>>> s = pd.Series(["hello", "world"])

Get a attribute.

>>> s.getattr("__doc__")
0    str(object='') -> str\nstr(bytes_or_buffer[, e...
1    str(object='') -> str\nstr(bytes_or_buffer[, e...
dtype: object

Get a don’t exist attribute.

>>> s.getattr("whatever")
0    None
1    None
dtype: object

Get a method attribute and call it.

>>> s.getattr("count", "l")
0    2
1    1
dtype: int64