查找给定 Pandas 系列中的单词长度
在这个任务中,我们将找到Pandas系列中字符串的长度。为此,我们将使用Pandas库中的函数。str.len()
算法
Step 1: Define a Pandas series of string. Step 2: Find the length of each string using the str.len() function. Step 3: Print the results.
示例代码
import pandas as pd
series = pd.Series(["Foo", "bar", "London", "Quarantine"])
print("Series: \n", series)
length = series.str.len()
print("Length:\n", length)输出结果Series: 0 Foo 1 bar 2 London 3 Quarantine dtype: object Length: 0 3 1 3 2 6 3 10 dtype: int64
热门推荐
6 保研的祝福语简短
10 年轻20岁祝福语简短
11 朋友结婚祝福语信息简短
12 女孩婚礼贺卡祝福语简短
13 30段点歌简短祝福语
14 虎年春节祝福语图文简短
15 写给后妈祝福语大全简短
16 简短回复生日祝福语
17 校长送毕业祝福语简短
18 毕业立体贺卡祝福语简短