首页 > 解决方案 > pairplot 数据未正确绘制

问题描述

问题:我有这个代码,它给了我一个错误:

AttributeError:“NoneType”对象没有属性“更新”

有什么建议么?太感谢了!

import seaborn as sns
features = ['rdeep','dtc','rhob', 'gr','npss']
feature_vectors=df[features]

feature_vectors = feature_vectors.apply(np.nan_to_num)
feature_vectors.reset_index(inplace=True, drop=True)
feature_vectors
sns.pairplot(feature_vectors, dropna=True )

这是全栈。这有帮助吗?

AttributeError                            Traceback (most recent call last)
<ipython-input-59-bf2539b2257e> in <module>
      6 feature_vectors.reset_index(inplace=True, drop=True)
      7 feature_vectors
----> 8 sns.pairplot(feature_vectors, dropna=True )

c:\program files\extensions\subpy_1.0.0.0\mc\lib\site-packages\seaborn\axisgrid.py

在pairplot(数据,色调,hue_order,调色板,vars,x_vars,y_vars,种类,diag_kind,标记,高度,方面,dropna,plot_kws,diag_kws,grid_kws,大小)2105 if grid.square_grid: 2106 if diag_kind == "hist ": -> 2107 grid.map_diag(plt.hist, **diag_kws) 2108 elif diag_kind == "kde": 2109 diag_kws.setdefault("shade", True)

c:\program files\extensions\subpy_1.0.0.0\mc\lib\site-packages\seaborn\axisgrid.py

在 map_diag(self, func, **kwargs) 1397 color = fixed_color 1398 -> 1399 func(data_k, label=label_k, color=color, **kwargs) 1400 1401 self._clean_axis(ax)

c:\program files\extensions\subpy_1.0.0.0\mc\lib\site-packages\matplotlib\pyplot.py

在 hist(x,bin,范围,密度,权重,累积,底部,histt​​ype,对齐,方向,rwidth,日志,颜色,标签,堆叠,规范,数据,**kwargs)2659 align=align,orientation=orientation, rwidth=rwidth, log=log, 2660 color=color, label=label, stacked=stacked, normed=normed, -> 2661 **({"data": data} if data is not None else {}), ** kwargs) 2662 2663

c:\program files\extensions\subpy_1.0.0.0\mc\lib\site-packages\matplotlib\__init__.py

在内部(ax,data,*args,**kwargs)1808“Matplotlib列表!)”%(label_namer,func.name ,1809 RuntimeWarning,stacklevel = 2)-> 1810返回func(ax,*args,* *kwargs) 1811 1812 内部。doc = _add_data_doc( inner.doc ,

c:\program files\extensions\subpy_1.0.0.0\mc\lib\site-packages\matplotlib\axes\_axes.py

in hist(self, x, bins, range, density, weights,cumulative, bottom, histt​​ype, align,orientation, rwidth, log, color, label,stacked, normed, **kwargs) 6533 # 单位转换在每个单独完成数据集 6534 self._process_unit_info(xdata=x[0], kwargs=kwargs) -> 6535 x = [self.convert_xunits(xi) for xi in x] 6536 6537 如果 bin_range 不是 None:

c:\program files\extensions\subpy_1.0.0.0\mc\lib\site-packages\matplotlib\axes\_axes.py

in (.0) 6533 # 单位转换在每个数据集上单独完成 6534 self._process_unit_info(xdata=x[0], kwargs=kwargs) -> 6535 x = [self.convert_xunits(xi) for xi in x] 6536 6537如果 bin_range 不是无:

c:\program files\extensions\subpy_1.0.0.0\mc\lib\site-packages\matplotlib\artist.py

在 convert_xunits(self, x) 184 如果 ax 为 None 或 ax.xaxis 为 None: 185 return x --> 186 return ax.xaxis.convert_units(x) 187 188 def convert_yunits(self, y):

c:\program files\extensions\subpy_1.0.0.0\mc\lib\site-packages\matplotlib\axis.py

在 convert_units(self, x) 1528 返回 x 1529 -> 1530 ret = self.converter.convert(x, self.units, self) 1531 返回 ret 1532

c:\program files\extensions\subpy_1.0.0.0\mc\lib\site-packages\matplotlib\category.py

in convert(value, unit, axis) 51 52 # 强制更新,因此它也会进行类型检查 ---> 53 unit.update(values) 54 55 str2idx = np.vectorize( unit._mapping.getitem ,

AttributeError: 'NoneType' object has no attribute 'update'

标签: seaborn

解决方案


推荐阅读