Python 3.x seaborn(ndim)的问题

Python 3.x seaborn(ndim)的问题,python-3.x,plot,seaborn,Python 3.x,Plot,Seaborn,我正在使用seaborn绘制一个非常简单的数据集。以下是我的工作: import seaborn as sns import pandas as pd df = pd.read_excel('myfile.xlsx') sns.set(style="white") g = sns.PairGrid(df, diag_sharey=False) g.map_lower(sns.kdeplot) g.map_upper(sns.scatterplot) g.map_diag(sns.kdepl

我正在使用
seaborn
绘制一个非常简单的数据集。以下是我的工作:

import seaborn as sns
import pandas as pd

df = pd.read_excel('myfile.xlsx')

sns.set(style="white")

g = sns.PairGrid(df, diag_sharey=False)
g.map_lower(sns.kdeplot)
g.map_upper(sns.scatterplot)
g.map_diag(sns.kdeplot, lw=3)
我得到以下错误:
AttributeError:'NoneType'对象没有属性“ndim”
。奇怪的是,这幅图是分部分绘制的(见下文)

你知道为什么会这样吗?我能做些什么来解决这个问题

编辑:

数据帧具有以下属性:

plan_change          int64
user_login         float64
new_act_ratio      float64
on_time              int64
不幸的是,我无法上传数据集。但是我可以说,绘制其他seaborn图形效果很好

总错误消息如下所示:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-16-2dbc61abd2bd> in <module>()
      3 g = sns.PairGrid(df, diag_sharey=False)
      4 g.map_lower(sns.kdeplot)
----> 5 g.map_upper(sns.scatterplot)
      6 g.map_diag(sns.kdeplot, lw=3)
      7 

/anaconda/lib/python3.5/site-packages/seaborn/axisgrid.py in map_upper(self, func, **kwargs)
   1488                 color = self.palette[k] if kw_color is None else kw_color
   1489                 func(data_k[x_var], data_k[y_var], label=label_k,
-> 1490                      color=color, **kwargs)
   1491 
   1492             self._clean_axis(ax)

/anaconda/lib/python3.5/site-packages/seaborn/relational.py in scatterplot(x, y, hue, style, size, data, palette, hue_order, hue_norm, sizes, size_order, size_norm, markers, style_order, x_bins, y_bins, units, estimator, ci, n_boot, alpha, x_jitter, y_jitter, legend, ax, **kwargs)
   1333         x_bins=x_bins, y_bins=y_bins,
   1334         estimator=estimator, ci=ci, n_boot=n_boot,
-> 1335         alpha=alpha, x_jitter=x_jitter, y_jitter=y_jitter, legend=legend,
   1336     )
   1337 

/anaconda/lib/python3.5/site-packages/seaborn/relational.py in __init__(self, x, y, hue, size, style, data, palette, hue_order, hue_norm, sizes, size_order, size_norm, dashes, markers, style_order, x_bins, y_bins, units, estimator, ci, n_boot, alpha, x_jitter, y_jitter, legend)
    850 
    851         plot_data = self.establish_variables(
--> 852             x, y, hue, size, style, units, data
    853         )
    854 

/anaconda/lib/python3.5/site-packages/seaborn/relational.py in establish_variables(self, x, y, hue, size, style, units, data)
    155                 units=units
    156             )
--> 157             plot_data = pd.DataFrame(plot_data)
    158 
    159         # Option 3:

/anaconda/lib/python3.5/site-packages/pandas/core/frame.py in __init__(self, data, index, columns, dtype, copy)
    264                                  dtype=dtype, copy=copy)
    265         elif isinstance(data, dict):
--> 266             mgr = self._init_dict(data, index, columns, dtype=dtype)
    267         elif isinstance(data, ma.MaskedArray):
    268             import numpy.ma.mrecords as mrecords

/anaconda/lib/python3.5/site-packages/pandas/core/frame.py in _init_dict(self, data, index, columns, dtype)
    400             arrays = [data[k] for k in keys]
    401 
--> 402         return _arrays_to_mgr(arrays, data_names, index, columns, dtype=dtype)
    403 
    404     def _init_ndarray(self, values, index, columns, dtype=None, copy=False):

/anaconda/lib/python3.5/site-packages/pandas/core/frame.py in _arrays_to_mgr(arrays, arr_names, index, columns, dtype)
   5382 
   5383     # don't force copy because getting jammed in an ndarray anyway
-> 5384     arrays = _homogenize(arrays, index, dtype)
   5385 
   5386     # from BlockManager perspective

/anaconda/lib/python3.5/site-packages/pandas/core/frame.py in _homogenize(data, index, dtype)
   5693                 v = lib.fast_multiget(v, oindex.values, default=NA)
   5694             v = _sanitize_array(v, index, dtype=dtype, copy=False,
-> 5695                                 raise_cast_failure=False)
   5696 
   5697         homogenized.append(v)

/anaconda/lib/python3.5/site-packages/pandas/core/series.py in _sanitize_array(data, index, dtype, copy, raise_cast_failure)
   2917 
   2918     # scalar like
-> 2919     if subarr.ndim == 0:
   2920         if isinstance(data, list):  # pragma: no cover
   2921             subarr = np.array(data, dtype=object)

AttributeError: 'NoneType' object has no attribute 'ndim'
---------------------------------------------------------------------------
AttributeError回溯(最近一次呼叫上次)
在()
3g=sns.PairGrid(df,diag\u sharey=False)
4 g.map_下(sns.kdeplot)
---->5 g地图上方(sns散点图)
6 g.map_diag(sns.kdeplot,lw=3)
7.
/地图上方的anaconda/lib/python3.5/site-packages/seaborn/axisgrid.py(self,func,**kwargs)
1488 color=self.palete[k]如果kw\u color不是其他kw\u color
1489 func(data_k[x_var],data_k[y_var],label=label_k,
->1490颜色=颜色,**千克)
1491
1492自清洁轴(ax)
/散点图中的anaconda/lib/python3.5/site-packages/seaborn/relational.py(x、y、色调、样式、大小、数据、调色板、色调顺序、色调规范、大小、大小顺序、大小规范、标记、样式顺序、x单元、y单元、估算器、ci、n单元启动、alpha、x单元抖动、y单元抖动、图例、ax、**kwargs)
1333个x_箱=x_箱,y_箱=y_箱,
1334估计器=估计器,ci=ci,n_boot=n_boot,
->1335阿尔法=阿尔法,x_抖动=x_抖动,y_抖动=y_抖动,图例=图例,
1336     )
1337
/anaconda/lib/python3.5/site-packages/seaborn/relational.py in_uuu_uinit_uuu(self、x、y、色调、大小、样式、数据、调色板、色调顺序、色调规范、大小、大小顺序、大小规范、虚线、标记、样式顺序、x_bin、y_bin、单位、估计器、ci、n_引导、alpha、x_抖动、y_抖动、图例)
850
851绘图数据=自建变量(
-->852 x,y,色调,大小,样式,单位,数据
853         )
854
/anaconda/lib/python3.5/site-packages/seaborn/relational.py在设置变量(self、x、y、色调、大小、样式、单位、数据)中
155个单位=个单位
156             )
-->157绘图数据=局部放电数据帧(绘图数据)
158
159#选项3:
/anaconda/lib/python3.5/site-packages/pandas/core/frame.py in_____________(self、数据、索引、列、数据类型、副本)
264数据类型=数据类型,复制=复制)
265 elif isinstance(数据、指令):
-->266 mgr=self.\u init\u dict(数据、索引、列、数据类型=dtype)
267 elif isinstance(数据,ma.MaskedArray):
268将numpy.ma.mrecords作为mrecords导入
/anaconda/lib/python3.5/site-packages/pandas/core/frame.py in_init_dict(self、data、index、columns、dtype)
400数组=[k个键的数据[k]
401
-->402将_数组_返回给_mgr(数组、数据名、索引、列、dtype=dtype)
403
404 def_init_ndarray(self、value、index、columns、dtype=None、copy=False):
/anaconda/lib/python3.5/site-packages/pandas/core/frame.py in_arrays_to_mgr(数组、arr_名称、索引、列、数据类型)
5382
5383#不要强行复制,因为不管怎么说,都会被排成一排
->5384数组=_同质化(数组、索引、数据类型)
5385
5386#从BlockManager的角度
/anaconda/lib/python3.5/site-packages/pandas/core/frame.py in_同质化(数据、索引、数据类型)
5693 v=lib.fast\u multiget(v,oindex.values,默认值=NA)
5694 v=_sanitize_数组(v,索引,dtype=dtype,copy=False,
->5695提升(铸造失败=错误)
5696
5697均质。附加(v)
/anaconda/lib/python3.5/site-packages/pandas/core/series.py在_sanitize_数组中(数据、索引、数据类型、复制、提升/转换失败)
2917
2918#标量型
->2919如果subar.ndim==0:
2920如果存在(数据、列表):#杂注:无封面
2921 subar=np.array(数据,dtype=object)
AttributeError:“非类型”对象没有属性“ndim”

myfile.xlsx的内容是什么?错误信息是什么(不仅仅是最后一行)?另请参见。谢谢您的快速回答!不幸的是,这次我无法提供数据集。但是我在问题中包括了
dtypes
和错误消息(参见“编辑”部分)