在python pandas中应用样式后,有没有方法删除列或行?然后重新分类?在
styled = df.style.apply(colorize, axis=None)
#remove _x columns
yonly = list(sorted(set(styled.columns) - set(df.filter(regex='_x$').columns)))
###Remove columns that end with "_x" here
styled.to_excel('styled.xlsx', engine='openpyxl', freeze_panes=(1,1))
我试过的大多数东西都是不可用的。
styled.reindex(columns=yonly)
返回AttributeError: 'Styler' object has no attribute 'reindex'
styled.columns = yonly
返回{
styled = styled[yonly]
返回
TypeError: 'Styler' object is not subscriptable
在@jezrael在设计和着色之前删除列的评论之后,我得到了我的答案:)
解决方案是传递一个额外的参数,使原始数据帧
df
可用。并且只给数据框df_tmp
加上“\y”的颜色。:)谢谢你们这么好的人!:天
相关问题 更多 >
编程相关推荐