maxframe.dataframe.Series.dict.remove#
- Series.dict.remove(query_key, ignore_key_error: bool = False)#
Remove the item by the key from each dict of the Series.
- Parameters:
query_key (Any) – The key to remove, must be in the same key type of the dict.
ignore_key_error (bool, optional, default False) – When the
query_key
is not in the dict, ifignore_key_error
is True, nothing will happen in the dict. Ifignore_key_error
isFalse
, anKeyError
will be raised. If the dict isNone
, returnsNone
.
- Returns:
A Series with the same data type. If the dict is
None
.- Return type:
- Raises:
KeyError : – If the
query_key
is not in one dict andignore_key_error
isFalse
.
Examples
Create a series with dict type data.
>>> import maxframe.dataframe as md >>> import pyarrow as pa >>> from maxframe.lib.dtypes_extension import dict_ >>> s = md.Series( ... data=[[("k1", 1), ("k2", 2)], [("k1", 3)], None], ... index=[1, 2, 3], ... dtype=map_(pa.string(), pa.int64()), ... ) >>> s.execute() 1 [('k1', 1), ('k2', 2)] 2 [('k1', 3)] 3 <NA> dtype: map<string, int64>[pyarrow]
>>> s.dict.remove("k2", ignore_key_error=True).execute() 1 [('k1', 1)] 2 [('k1', 3)] 3 <NA> dtype: map<string, int64>[pyarrow]