下载依赖
pip install openpyxl -i https://pypi.doubanio.com/simple
pip install pandas -i https://pypi.doubanio.com/simple
引入依赖
from openpyxl import load_workbook
from openpyxl import styles
from openpyxl.styles import *
import pandas as pd
import string
数据读入
filePath1 = './src/超级原始数据精修.xlsx'# 加载工作簿wb = load_workbook(filePath1)# 获取sheet页,修改第一个sheet页面为name1 = wb.sheetnames[0]ws1 = wb[name1]ws1.title = "销售明细"#销售明细df0 = pd.read_excel(filePath1, sheet_name='销售明细')
计算每周数据,并添加新列
获取表头字符串
# 获取列名
#column_names = df.columns
column_names_list = df0.columns.values
#获取列长度
col_num = len(column_names_list)
指定列求和
使用iloc选择要求和的列:
df