Van*_*ika 3 python series dataframe pandas
我正在尝试使用pandas.Series.explode 计算数据框列中唯一值的数量, 因为我对分解整个数据框不感兴趣。我试图爆炸的数据框列看起来像
df["lists"].head()
0 [cl5, bn6, sp1]
1 [cl5, bn6, sp1]
2 [cl5, bn6, sp1]
3 [bn6, sp1]
4 [bn6, sp1]
Name: lists, dtype: object
Run Code Online (Sandbox Code Playgroud)
我尝试df.lists.explode().value_counts()
抛出一个AttributeError : 'Series' object has no attribute 'explode'。用爆炸整个数据帧时观察到相同的错误df.explode('lists')
。我看不到它是否已被弃用,所以当源示例也不起作用时,我不确定有什么问题。