请用python写一段代码:根据excel表中缴费时间及购电量,计算每个自然月用电量...

答:# 导入需要的库 import pandas as pd# 读取excel表格 df = pd.read_excel('excel表格.xlsx')# 根据缴费时间计算每个自然月的用电量 df['自然月用电量'] = df.groupby(df['缴费时间'].dt.to_period('M'))['购电量'].transform('sum')# 打印结果 print(df)

猜你喜欢

转载自blog.csdn.net/weixin_42601702/article/details/129551597
今日推荐