【发布时间】:2018-02-24 02:04:48
【问题描述】:
我有一个 DataFrame,它有一个字符串列,如下所示:
id text label
1 this is long string with many words 1
2 this is a middle string 0
3 short string 1
我想根据字符串长度将这个 DataFrame 转换为另一个 DataFrame,即 (df['text'].str.len > 3):
id text label
1 this is long 1
1 string with many 1
1 words 1
2 this is a 0
2 middle string 0
3 short string 1
这是我的代码:
pd.concat(df['text'].str.len() > 200)
但这是错误的。
【问题讨论】: