AttributeError:“索引”对象没有属性“ remove_unused_levels”

时间:2019-11-08 08:52:37

标签: python-3.x

大家好,我收到以下错误消息:

AttributeError: 'Index' object has no attribute 'remove_unused_levels'

回溯看起来像: 追溯(最近一次通话):

File "/home/sampath/Documents/parsertool/RankCV.py", line 47, in plot_ranking_chart
    final_database2 = final_database['Candidate Name'].groupby(final_database['Keyword']).count().unstack()
  File "/home/sampath/environments/project_env/lib/python3.7/site-packages/pandas/core/series.py", line 2899, in unstack
    return unstack(self, level, fill_value)
  File "/home/sampath/environments/project_env/lib/python3.7/site-packages/pandas/core/reshape/reshape.py", line 501, in unstack
    constructor=obj._constructor_expanddim)
  File "/home/sampath/environments/project_env/lib/python3.7/site-packages/pandas/core/reshape/reshape.py", line 116, in __init__
    self.index = index.remove_unused_levels()
AttributeError: 'Index' object has no attribute 'remove_unused_levels'

运行以下代码时:

final_database2 = final_database['Candidate Name'].groupby(final_database['Keyword']).count().unstack()
final_database2.reset_index(inplace = True)
final_database2.fillna(0,inplace=True)
new_data = final_database2.iloc[:,1:]
new_data.index = final_database2['Keyword']
return new_data

我不明白这是什么错误。有人可以解释吗?

0 个答案:

没有答案