繁体   English   中英

类型错误:不支持 / 的操作数类型:'str' 和 'int' (2)

[英]TypeError: unsupported operand type(s) for /: 'str' and 'int' (2)

我正在尝试显示包含数字和字母的数据集中的图表。

grouped = pd.DataFrame(train.groupby(['shop_id', 'date_block_num'])['item_cnt_day'].sum().reset_index())
fig, axes = plt.subplots(nrows=5, ncols=2, sharex=True, sharey=True, figsize=(16,20))
num_graph = 10
id_per_graph = ceil(grouped.shop_id.max() / num_graph)
count = 0
for i in range(5):
    for j in range(2):
        sns.pointplot(x='date_block_num', y='item_cnt_day', hue='shop_id', data=grouped[np.logical_and(count*id_per_graph <= grouped['shop_id'], grouped['shop_id'] < (count+1)*id_per_graph)], ax=axes[i][j])
        count += 1

然后,它说:

TypeError                                 Traceback (most recent call last)
<ipython-input-19-77428a365041> in <module>
      2 fig, axes = plt.subplots(nrows=5, ncols=2, sharex=True, sharey=True, figsize=(16,20))
      3 num_graph = 10
----> 4 id_per_graph = ceil(grouped.shop_id.max() / num_graph)
      5 count = 0
      6 for i in range(5):

TypeError: unsupported operand type(s) for /: 'str' and 'int'

尝试id_per_graph = ceil(max(grouped.shop_id) / num_graph)你使用的是.max()错误

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM