【问题标题】:how can we remove the single key from multiple keys in a dictionary?我们如何从字典中的多个键中删除单个键?
【发布时间】:2020-11-16 13:32:43
【问题描述】:

我的数据框有 4 列,如行、列、管和评级。转换为字典后,我从列名中获取了一个额外的元素作为字符串。我们如何从字典中删除字符串。

nn = final_als_ho[['rows','tube', 'cols', 'rating']] nn = nn.set_index(['rows', 'tube', 'cols']).stack(0).to_dict()

【问题讨论】:

    标签: math statistics linear-algebra tensor factorization


    【解决方案1】:

    如果您使用的是 python,我已经创建了一个方法来做到这一点

    您需要创建另一个字典2 然后遍历第一个字典1 如果字典不包含特定值,则将值附加到字典2

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-19
      • 2022-08-08
      • 2012-02-18
      • 2021-11-18
      • 2016-03-12
      • 1970-01-01
      • 1970-01-01
      • 2018-12-24
      相关资源
      最近更新 更多