Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
按两个标准分组的直方图[python]_Python_Pandas_Histogram_Seaborn - Fatal编程技术网

按两个标准分组的直方图[python]

按两个标准分组的直方图[python],python,pandas,histogram,seaborn,Python,Pandas,Histogram,Seaborn,我有这样一个数据集: 我需要根据两个标准绘制这个数据集:客户流失和客户价值 我可以使用seaborn: sns.barplot(x="Cust_Value", y="value", hue="Churn", data=merged) plt.show() 结果给了我: 如何将所有变量(值、年龄、重新加载、呼叫、持续时间、sms、gprs、非活动)添加到与条形图组相同的图形中?对于此类输出,我建议使用plotly import plotly.plotly as py import plotl

我有这样一个数据集:

我需要根据两个标准绘制这个数据集:客户流失和客户价值

我可以使用seaborn:

sns.barplot(x="Cust_Value", y="value", hue="Churn", data=merged)
plt.show()
结果给了我:


如何将所有变量(值、年龄、重新加载、呼叫、持续时间、sms、gprs、非活动)添加到与条形图组相同的图形中?

对于此类输出,我建议使用plotly

import plotly.plotly as py
import plotly.graph_objs as go

trace1 = go.Bar(
    x=DF['Cust_Value'],
    y=DF['value'],
    name='value'
)
trace2 = go.Bar(
    x=DF['Cust_Value'],
    y=DF['age'],
    name='age'
)
trace3 = go.Bar(
    x=DF['Cust_Value'],
    y=DF['calls'],
    name='calls'
)

data = [trace1, trace2, trace3]
layout = go.Layout(
    barmode='group'
)

fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename='grouped-bar')
样本输出:

参考:

希望有帮助

如果它没有投票:)


和平

尝试融化数据,如图所示。