如何使用openpyxl和Pandas自动化代码?

2024-04-28 12:10:58 发布

您现在位置:Python中文网/ 问答频道 /正文

关于openpyxl和pandas,我有几个问题需要自动化,这与数据帧DF的长度有关

第一个是关于细胞。我想自动化其中的每一行,如果它只打印行数等于从第3行开始的数据帧长度的边框

       A3 = ws['A3'] 
       A3.border = Border(top=thin, left=thin, right=thin, bottom=thin)
       A3.alignment=Alignment(horizontal='general',
         vertical='bottom',
         text_rotation=0,
         wrap_text=True,
         shrink_to_fit=False,
         indent=0)
       A4 = ws['A4'] 
       A4.border = Border(top=thin, left=thin, right=thin, bottom=thin)
       A4.alignment=Alignment(horizontal='general',
         vertical='bottom',
         text_rotation=0,
         wrap_text=True,
         shrink_to_fit=False,
         indent=0)

第二个是关于数据帧。我想根据数据帧的长度,将“None”添加到df列多次

note =  [None, None, None,None,None,None,None,None]
df['Note'] = note

Tags: 数据textrightnonewstoplefta3