小编Van*_*ika的帖子

pandas.Series.explode 抛出 AttributeError

我正在尝试使用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')。我看不到它是否已被弃用,所以当源示例也不起作用时,我不确定有什么问题。

python series dataframe pandas

3
推荐指数
1
解决办法
8362
查看次数

标签 统计

dataframe ×1

pandas ×1

python ×1

series ×1