简体   繁体   English

如何在我的数据框中只加粗一列以便导出到 Excel?

[英]How can I bold just one column in my dataframe so I can export to an excel?

I have been reading documentation and some questions here, but I only found solutions with conditions, I have some columns in my dataframe that I want to bold and then concatenate.我一直在这里阅读文档和一些问题,但我只找到了有条件的解决方案,我的数据框中有一些列我想加粗然后连接。

My dataframe it´s like this:我的数据框是这样的:

Name姓名 Product产品
Paul保罗 Produc1产品1
Jhon product2产品2

I want all the values in my column(Paul, Jhon) to be bold so I can export that to an excel.我希望我的列(Paul,Jhon)中的所有值都是粗体,以便我可以将其导出到 Excel。

Let's try我们试试看

df.style.applymap(lambda x: 'font-weight: bold;', subset='Name')\
        .to_excel('output.xlsx')

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

相关问题 如何在Pandas中更新DataFrame并导出到Excel? - How can I update my DataFrame in Pandas and export out to Excel? 如何将我的 Tkinter 条目的数据存储到 DataFrame 中,以便稍后将其导出到 Excel? - How can I store the data of my Tkinter entries into a DataFrame to later export it to Excel? 如何在 ubuntu 中给出将 dataframe 导出到 excel 文件的路径? - how can i give the path to export a dataframe to excel file in ubuntu? 如何使用openpyxl将['apple','carrots','mango']之类的列表导出到excel的一栏中? 在Python中 - How can I export a list such as ['apple', 'carrots', 'mango'] into one column in excel with openpyxl? In Python 如何转换 DataFrame 以便标题成为列值? - How can I transform a DataFrame so that the headers become column values? 如何正确地将我的 json 导出到 pandas 中的 dataframe - How can i export correctly my json to a dataframe in pandas 如何将NUMPY数组导出到CSV或EXCEL文件 - How can I export my NUMPY array into a CSV or EXCEL file 如何将一列从一个数据帧添加到另一个数据帧? - How can I add a column from one dataframe to another dataframe? 如何仅将 CSV 中的一列读取到我的 Dynamodb 表中? - How can I read just one column from CSV into my Dynamodb table? 如何格式化谷歌表格以便正确导出我的数据? - How can I format google sheets so I can export my data properly?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM