查找给定 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
热门推荐
10 姑娘生日祝福语简短的话
11 店家搬家祝福语大全简短
12 空军大学开学祝福语简短
13 老板茶楼开业祝福语简短
14 思念丈夫祝福语简短的话
15 送弟弟中秋祝福语简短
16 虎年送火腿祝福语简短
17 养生祝福语女生短句简短
18 日语送考祝福语简短