查找给定 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 出阁宴祝福语姐姐简短