Skip to content

Latest commit

 

History

History
45 lines (34 loc) · 909 Bytes

186.md

File metadata and controls

45 lines (34 loc) · 909 Bytes
@author jackzhenguo
@desc
@tag
@version 
@date 2020/03/24

第186个小例子:使用 count 统计词条 出现次数

读入 IMDB-Movie-Data 数据集,1000行数据:

df = pd.read_csv("../input/imdb-data/IMDB-Movie-Data.csv")
df['Title']

打印 Title 列:

0      Guardians of the Galaxy
1                   Prometheus
2                        Split
3                         Sing
4                Suicide Squad
                ...
995       Secret in Their Eyes
996            Hostel: Part II
997     Step Up 2: The Streets
998               Search Party
999                 Nine Lives
Name: Title, Length: 1000, dtype: object

标题是由几个单词组成,用空格分隔。

df["words_count"] = df["Title"].str.count(" ") + 1
df[["Title","words_count"]]
[上一个例子](185.md) [下一个例子](187.md)