python - Python Change theColor of Column in a Dataframe then merge the Frame
问题描述
I have multiple Data Frames lets say; | Date | Name | Value | |:---- |:------:| -----:| |01.01 | A | 20 | |02.01 | B | Null | |03.01 | C | 10 | and | Date | Name | Value_2 | |:---- |:------:| -------:| |01.01 | A | 20 | |02.01 | B | 10 | |03.01 | C | 10 |
I want to make Value_2 column red then merge these table as | Date | Name | Value |Value_2 | |:---- |:------:| -----:|-------:| |01.01 | A | 20 | 10 | |02.01 | B | Null | 10 | |03.01 | C | 10 | 10 | and then change the null value with value2
Without formatting my codes works perfectly, but if change the value2_2 column name with
''' col_ref = {'value': 'color: red'}
df=df.style.apply(lambda x: pd.DataFrame(col_ref, index=df.index, columns=df.columns).fillna(''),axis=None) '''
I cant do merging or dropping. I know after using style it is no more Dataframe so I can't do these operation. But is there any other way to this process. The reason is to save the final form to excel and be able to see where these data coming from (value or value_2)
解决方案
推荐阅读
- sql - 需要有可以为任何动态给定查询生成 CSV 文件的 SSIS 包
- c# - 素数查找器 C#
- mysql - SQL 键,外键有点太锁定了
- c++ - arg 方向的“in”和“out”是什么意思?
- php - 在 Laravel Blade 中使用 {{ Str::limit }} 辅助类时出错
- java - 如何在Scala中实现扩展Comparable且没有特定类型的Java接口?
- angular - Angular 6 - 如何根据变量的值注册不同的路由
- objective-c - 如何在 Sharpie 中正确设置范围?
- .net-core - 导航到英文 /en/ 站点时,路由模板会导致 404
- excel - 使用 Excel 数据库将项目添加到 datagridview