【发布时间】:2020-06-11 22:33:33
【问题描述】:
我有如下代码:
goodCredit = data[data["Risk"] == 'good']
badCredit = data[data["Risk"] == 'bad']
bar1SA = go.Bar(
x = goodCredit["Saving accounts"].value_counts().index.values,
y = goodCredit["Saving accounts"].value_counts().values,
name='Good credit')
bar2SA = go.Bar(
x = badCredit["Saving accounts"].value_counts().index.values,
y = badCredit["Saving accounts"].value_counts().values,
name='Bad credit')
bar1CA = go.Box(
x=goodCredit["Checking account"].value_counts().index.values,
y=goodCredit["Checking account"].value_counts().values,
name='Good credit')
bar2CA = go.Box(
x=badCredit["Checking account"].value_counts().index.values,
y=badCredit["Checking account"].value_counts().values,
name='Bad credit')
data = [bar1SA, bar2SA, bar1CA, bar2CA]
fig = tls.make_subplots(rows=1, cols=2,
subplot_titles=('Count Saving Accounts','Count Checking account'))
fig.append_trace(bar1SA, 1, 1)
fig.append_trace(bar2SA, 1, 1)
fig.append_trace(bar1CA, 1, 2)
fig.append_trace(bar2CA, 1, 2)
fig['layout'].update(height=700, width=800, title='Saving Accounts and Checking account Exploration based on risk')
py.iplot(fig, filename='SAiCAdistribution')
结果如下:
代码哪里出错了,因为你可以看到第二个情节不好,它应该和第一个情节相似。
【问题讨论】:
标签: python pandas plotly seaborn