python:matplotlib 3D plot:TypeError:unhashable类型

时间:2016-09-19 00:27:49

标签: python matplotlib pyspark spark-dataframe

%matplotlib notebook
import matplotlib

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure(1, figsize=(4, 3))
plt.clf()
ax = Axes3D(fig, rect=[0, 0, .95, 1], elev=48, azim=134)
result_pandas = my_df.toPandas()
ax.scatter(my_df[:, 'field_A'], my_df[:, 'field_B'], my_df[:, 'field_C'], c=my_df[:, 'prediction'])

但出现以下错误:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-36-6c69cf98c792> in <module>()
     10 ax = Axes3D(fig, rect=[0, 0, .95, 1], elev=48, azim=134)
     11 result_pandas = my_df.toPandas()
---> 12 ax.scatter(result_pandas[:, 'esx_max_uptime_day'], result_pandas[:, 'esx_count_last_biweek'], result_pandas[:, 'vc_usr_count'], c=result_pandas[:, 'prediction'])

/home/edamame/anaconda2/lib/python2.7/site-packages/pandas/core/frame.pyc in __getitem__(self, key)
   1995             return self._getitem_multilevel(key)
   1996         else:
-> 1997             return self._getitem_column(key)
   1998 
   1999     def _getitem_column(self, key):

/home/edamame/anaconda2/lib/python2.7/site-packages/pandas/core/frame.pyc in _getitem_column(self, key)
   2002         # get column
   2003         if self.columns.is_unique:
-> 2004             return self._get_item_cache(key)
   2005 
   2006         # duplicate columns & possible reduce dimensionality

/home/edamame/anaconda2/lib/python2.7/site-packages/pandas/core/generic.pyc in _get_item_cache(self, item)
   1346         """Return the cached item, item represents a label indexer."""
   1347         cache = self._item_cache
-> 1348         res = cache.get(item)
   1349         if res is None:
   1350             values = self._data.get(item)

TypeError: unhashable type

知道这里有什么问题吗?谢谢!

0 个答案:

没有答案