【问题标题】:AttributeError: 'Styler' object has no attribute 'merge'AttributeError:“Styler”对象没有“合并”属性
【发布时间】:2020-03-04 08:48:17
【问题描述】:

我有一个这样的问题,当我用熊猫设置数据(条件格式)时,我无法合并这些数据。您可以在下面找到我的代码和错误, 谁能给我一个建议?

代码:

cm = sns.diverging_palette(10, 140, s=99, l=50,
                              n=9, center="light", as_cmap=True)

df_style1 = df_b.style.background_gradient(cmap=cm)
df_style2 = df_c.style.background_gradient(cmap=cm)
df_last = df_style1.merge(df_style2, on= 'EKSPER_ADI', how='left')

错误:

AttributeError                            Traceback (most recent call last)
 <ipython-input-148-d1b2ae3dc7a6> in <module>
  4 df_style1 = df_b.style.background_gradient(cmap=cm)
  5 df_style2 = df_c.style.background_gradient(cmap=cm)
  ----> 6 df_last = df_style1.merge(df_style1, on= 'EKSPER_ADI', how='left')

 AttributeError: 'Styler' object has no attribute 'merge'

【问题讨论】:

    标签: pandas numpy merge attributeerror pandas-styles


    【解决方案1】:

    我觉得不可能,先用merge再申请styles:

    df = df_b.merge(df_c, on= 'EKSPER_ADI', how='left')
    df_style2 = df.style.background_gradient(cmap=cm)
    

    【讨论】:

    • 请详细说明
    猜你喜欢
    • 2021-08-24
    • 1970-01-01
    • 1970-01-01
    • 2012-12-01
    • 2021-04-19
    • 2021-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多