新答案
OP 想'none'
从子列表中删除并仅删除行'none'
us_videos.tags.explode().pipe(lambda s: s[s != 'none']).groupby(level=0).agg(list)
0 [marvel, comics, comic, books, nerdy]
1 [new, snapchat, version, snap, inc]
3 [new, york, times, ny, times, nyt, times]
4 [today, show, today, show, today]
6 [mark, wahlberg, marky, mark]
Name: tags, dtype: object
一种更pythonic的方式
dat = {}
for k, v in us_videos.tags.iteritems():
for x in v:
if x != 'none':
dat.setdefault(k, []).append(x)
pd.Series(dat, name='tags')
0 [marvel, comics, comic, books, nerdy]
1 [new, snapchat, version, snap, inc]
3 [new, york, times, ny, times, nyt, times]
4 [today, show, today, show, today]
6 [mark, wahlberg, marky, mark]
Name: tags, dtype: object
在推导式中使用赋值表达式
pd.Series({
k: X for k, v in us_videos.tags.iteritems()
if (X:=[*filter('none'.__ne__, v)])
}, name='tags')
0 [marvel, comics, comic, books, nerdy]
1 [new, snapchat, version, snap, inc]
3 [new, york, times, ny, times, nyt, times]
4 [today, show, today, show, today]
6 [mark, wahlberg, marky, mark]
Name: tags, dtype: object
旧答案
explode
us_videos[us_videos.tags.explode().ne('none').any(level=0)]
tags
0 [marvel, comics, comic, books, nerdy]
1 [new, snapchat, version, snap, inc]
3 [new, york, times, ny, times, nyt, times]
4 [today, show, today, show, today]
6 [mark, wahlberg, marky, mark]
list.__ne__
us_videos[us_videos.tags.map(['none'].__ne__)]
tags
0 [marvel, comics, comic, books, nerdy]
1 [new, snapchat, version, snap, inc]
3 [new, york, times, ny, times, nyt, times]
4 [today, show, today, show, today]
6 [mark, wahlberg, marky, mark]