我在自动化有关 openpyxl 和 pandas 的数据时遇到了一些问题,这些问题与 Dataframe 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
最佳答案
对于第二个问题,你可以简单地做,IIUC:
df['Note'] = None
关于python - 如何使用 openpyxl 和 Pandas 自动化我的代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59121193/