python - 我如何解决我的 Birch Clustering PyPlot 错误问题
问题描述
我对我的数据进行了 Birch 聚类分析。之后,我尝试使用下面的代码来绘制我的分析,然后我得到了这个错误。我该如何解决?谢谢你。
# create scatter plot for samples from each cluster
for cluster in clusters:
# get row indexes for samples with this cluster
row_ix = where(yhat == cluster)
# create scatter of these samples
pyplot.scatter(dfAB1[row_ix, 0], dfAB1[row_ix, 1])
# show the plot
pyplot.show()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-24-840a4662002f> in <module>
4 row_ix = where(yhat == cluster)
5 # create scatter of these samples
----> 6 pyplot.scatter(dfAB1[row_ix, 0], dfAB1[row_ix, 1])
~\anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key)
3022 if self.columns.nlevels > 1:
3023 return self._getitem_multilevel(key)
-> 3024 indexer = self.columns.get_loc(key)
3025 if is_integer(indexer):
3026 indexer = [indexer]
~\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
3078 casted_key = self._maybe_cast_indexer(key)
3079 try:
-> 3080 return self._engine.get_loc(casted_key)
3081 except KeyError as err:
3082 raise KeyError(key) from err
pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
TypeError: '((array([3586, 3591, 3592, ..., 6982, 6983, 6984], dtype=int64),), 0)' is an invalid key
解决方案
推荐阅读
- python-3.x - ValueError("I/O operation on closed pipe") 将异步与子进程一起使用时
- sharepoint-online - 重置样本 ID 的增量变量
- python - 使用 Python 导入 R 脚本的输出
- python - Python 3 str.format 带小数位
- python - 自动重构长 python 导入列表
- r - 根据 R 中的列名或变量,用 NA 填充整个列
- django - 带有 IN + LIKE 的 Django ORM 查询
- r - 使用另一列中的条件将值从一列复制到 NA
- python - 如何使用正则表达式提高 beautifulsoup 中文本搜索的准确性,和/或从“要排除的文本字符串”列表中过滤项目?
- c++ - 是否在特定实现上定义了两个数组之间的指针差异?