maxframe.dataframe.Series.dict.len#
- Series.dict.len()#
获取 Series 中每个字典的长度。
- 返回:
一个数据类型为
pandas.ArrowDtype(pyarrow.int64)的 Series。每个元素表示字典的长度,如果字典为None,则对应元素为None。- 返回类型:
示例
创建一个包含字典类型数据的 Series。
>>> 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.len().execute() 1 2 2 1 3 <NA> dtype: int64[pyarrow]