maxframe.dataframe.Series.str.len#
- Series.str.len()#
计算 Series/Index 中每个元素的长度。
元素可以是一个序列(如字符串、元组或列表)或一个集合(如字典)。
参见
str.lenPython 内置函数,返回对象的长度。
Series.size返回 Series 的长度。
示例
返回字符串中的长度(字符数)。对于字典、列表或元组,返回其中条目的数量。
>>> import maxframe.dataframe as md >>> s = md.Series( ... ["dog", "", 5, {"foo": "bar"}, [2, 3, 5, 7], ("one", "two", "three")] ... ) >>> s.execute() 0 dog 1 2 5 3 {'foo': 'bar'} 4 [2, 3, 5, 7] 5 (one, two, three) dtype: object >>> s.str.len().execute() 0 3.0 1 0.0 2 NaN 3 1.0 4 4.0 5 3.0 dtype: float64