maxframe.dataframe.Series.list.len#
- Series.list.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 list_ >>> s = md.Series( ... data=[[1, 2, 3], [4, 5, 6], None], ... index=[1, 2, 3], ... dtype=list_(pa.int64()), ... ) >>> s.execute() 1 [1, 2, 3] 2 [4, 5, 6] 3 <NA> dtype: list<int64>[pyarrow]
>>> s.list.len().execute() 1 2 2 1 3 <NA> dtype: int64[pyarrow]