如何绘制分类图与分类图?

问题描述 投票:0回答:1

我想检查类别计数(在第一列中)与类别计数在第二列中。我有两列:1. Max_glu_serum,类别:无,标准,<200,<300。2.按类别分类:否,<30,> 30。

[我想要一个图,以便可以检查'> 30'时'<300'的计数,即,有多少患者的max_glu_serum => 300并且在'> 30'天内被重新接纳]]

我尝试了以下代码:

sns.catplot(y=train_data_wmis['max_glu_serum'], 
        hue=train_data_wmis['readmitted'], 
        kind="count", 
        palette="pastel", edgecolor=".6", dropna=True)

但它引发以下错误:

TypeError                                 Traceback (most recent call last)
<ipython-input-384-1be2c9032203> in <module>
----> 1 sns.catplot(y=train_data_wmis['max_glu_serum'], hue=train_data_wmis['readmitted'], kind="count", palette="pastel", edgecolor=".6", dropna=True)

F:\Anaconda3\lib\site-packages\seaborn\categorical.py in catplot(x, y, hue, data, row, col, col_wrap, estimator, ci, n_boot, units, order, hue_order, row_order, col_order, kind, height, aspect, orient, color, palette, legend, legend_out, sharex, sharey, margin_titles, facet_kws, **kwargs)
   3750 
   3751     # Initialize the facets
-> 3752     g = FacetGrid(**facet_kws)
   3753 
   3754     # Draw the plot onto the facets

F:\Anaconda3\lib\site-packages\seaborn\axisgrid.py in __init__(self, data, row, col, hue, col_wrap, sharex, sharey, height, aspect, palette, row_order, col_order, hue_order, hue_kws, dropna, legend_out, despine, margin_titles, xlim, ylim, subplot_kws, gridspec_kws, size)
    255         # Make a boolean mask that is True anywhere there is an NA
    256         # value in one of the faceting variables, but only if dropna is True
--> 257         none_na = np.zeros(len(data), np.bool)
    258         if dropna:
    259             row_na = none_na if row is None else data[row].isnull()

TypeError: object of type 'NoneType' has no len()

有人可以帮我吗!

我想检查类别计数(在第一列中)与类别计数在第二列中。我有两列:1.具有类别的Max_glu_serum:无,范数,<200,<300。 2. ...

python-3.x pandas seaborn categorical-data
1个回答
0
投票

我尝试了几件事,终于找到了解决上述问题的一种方法。定义了以下功能:

© www.soinside.com 2019 - 2024. All rights reserved.