diff --git a/入模数据/丽水.xlsx b/入模数据/丽水.xlsx index 78ca218..3ecd108 100644 Binary files a/入模数据/丽水.xlsx and b/入模数据/丽水.xlsx differ diff --git a/入模数据/台州.xlsx b/入模数据/台州.xlsx index 7f4d426..7263cb0 100644 Binary files a/入模数据/台州.xlsx and b/入模数据/台州.xlsx differ diff --git a/入模数据/嘉兴.xlsx b/入模数据/嘉兴.xlsx index b8dacc6..937b2ca 100644 Binary files a/入模数据/嘉兴.xlsx and b/入模数据/嘉兴.xlsx differ diff --git a/入模数据/宁波.xlsx b/入模数据/宁波.xlsx index 580b786..5995cb9 100644 Binary files a/入模数据/宁波.xlsx and b/入模数据/宁波.xlsx differ diff --git a/入模数据/杭州.xlsx b/入模数据/杭州.xlsx index 0c6e50a..3617ba1 100644 Binary files a/入模数据/杭州.xlsx and b/入模数据/杭州.xlsx differ diff --git a/入模数据/温州.xlsx b/入模数据/温州.xlsx index 5303d5b..5121488 100644 Binary files a/入模数据/温州.xlsx and b/入模数据/温州.xlsx differ diff --git a/入模数据/湖州.xlsx b/入模数据/湖州.xlsx index de927f5..c350cf0 100644 Binary files a/入模数据/湖州.xlsx and b/入模数据/湖州.xlsx differ diff --git a/入模数据/绍兴.xlsx b/入模数据/绍兴.xlsx index 206ecfe..1dcd1d1 100644 Binary files a/入模数据/绍兴.xlsx and b/入模数据/绍兴.xlsx differ diff --git a/入模数据/舟山.xlsx b/入模数据/舟山.xlsx index d7824d9..66ee09d 100644 Binary files a/入模数据/舟山.xlsx and b/入模数据/舟山.xlsx differ diff --git a/入模数据/衢州.xlsx b/入模数据/衢州.xlsx index 5f996da..b4328f3 100644 Binary files a/入模数据/衢州.xlsx and b/入模数据/衢州.xlsx differ diff --git a/入模数据/金华.xlsx b/入模数据/金华.xlsx index 3608a1c..c9ab342 100644 Binary files a/入模数据/金华.xlsx and b/入模数据/金华.xlsx differ diff --git a/各地级市日电量模型/jiaxing.bin b/各地级市日电量模型/jiaxing.bin index 1e89ba7..f2dc1c5 100644 Binary files a/各地级市日电量模型/jiaxing.bin and b/各地级市日电量模型/jiaxing.bin differ diff --git a/各地级市日电量模型/丽水.py b/各地级市日电量模型/丽水.py index 614f2ad..8fdb9f7 100644 --- a/各地级市日电量模型/丽水.py +++ b/各地级市日电量模型/丽水.py @@ -83,19 +83,20 @@ print(goal2) import numpy as np X_eval = np.array([ - [11.59, 0.6, 0, 0, 1, 2023], - [16.6, 2.4, 0, 0, 1, 2023], - [15.5, 6.7, 0, 0, 1, 2023], - [15, 9.4, 0, 0, 1, 2023], - [18.6, 7.5, 0, 1, 1, 2023] + [16.2, 3.2, 0, 0, 1, 2023], + [17.9, 6.4, 0, 0, 1, 2023], + [15.7, 9.0, 0, 0, 1, 2023], + [19.2, 8.1, 0, 3, 1, 2023], + [11.8, 2.4, 0, 3, 1, 2023] ]) +# X_eval = np.array([[6.2,5.1,0,0,1,2023]]) print(model.predict(X_eval)) result = model.predict(X_eval) -result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28','2023-12-29','2023-12-30']) +result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28','2023-12-29','2023-12-30','2023-12-31' ]) result = pd.concat((result_eval['eval'], result)) result.index = result.index.map(lambda x: str(x)[:10]) result.columns = ['预测值'] print(result) -with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1227.xlsx',mode='a',if_sheet_exists='replace',engine='openpyxl') as writer: +with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx',mode='a',if_sheet_exists='replace',engine='openpyxl') as writer: result.to_excel(writer,sheet_name='丽水') \ No newline at end of file diff --git a/各地级市日电量模型/台州.py b/各地级市日电量模型/台州.py index 77f7812..8c6a1ef 100644 --- a/各地级市日电量模型/台州.py +++ b/各地级市日电量模型/台州.py @@ -82,20 +82,20 @@ print(result_eval) import numpy as np X_eval = np.array([ - [13.1, -0.7, 0, 0, 1, 2023], - [17.9, 2.8, 0, 0, 1, 2023], - [15.8, 7.6, 0, 0, 1, 2023], - [15.9, 8, 0, 0, 1, 2023], - [19.7, 7.8, 0, 1, 1, 2023] + [17.3, 2.2, 0, 0, 1, 2023], + [19, 5.5, 0, 0, 1, 2023], + [16, 6.5, 0, 0, 1, 2023], + [19.7, 7.9, 0, 3, 1, 2023], + [11.9, 3.2, 0, 3, 1, 2023] ]) print(model.predict(X_eval)) result = model.predict(X_eval) -result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30']) +result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31']) result = pd.concat((result_eval['eval'], result)) result.index = result.index.map(lambda x: str(x)[:10]) result.columns = ['预测值'] print(result) -with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace', +with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace', engine='openpyxl') as writer: result.to_excel(writer, sheet_name='台州') diff --git a/各地级市日电量模型/嘉兴.py b/各地级市日电量模型/嘉兴.py index 0511d7c..4993ce2 100644 --- a/各地级市日电量模型/嘉兴.py +++ b/各地级市日电量模型/嘉兴.py @@ -81,20 +81,20 @@ loaded_model.load_model('jiaxing.bin') import numpy as np X_eval = np.array([ - [10.7, -2.2, 0, 0, 1, 2023], - [12.8, 2.2, 0, 0, 1, 2023], - [11.7, 2.3, 0, 0, 1, 2023], - [13, 1, 0, 0, 1, 2023], - [11.5, 5.8, 0, 1, 1, 2023] + [13.8, 2.1, 0, 0, 1, 2023], + [12.1, 1.7, 0, 0, 1, 2023], + [10.3, 3.0, 0, 0, 1, 2023], + [12.1, 7.1, 0, 3, 1, 2023], + [8.2, 1.3, 0, 3, 1, 2023] ]) print(model.predict(X_eval)) result = model.predict(X_eval) -result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30']) +result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31']) result = pd.concat((result_eval['eval'], result)) result.index = result.index.map(lambda x: str(x)[:10]) result.columns = ['预测值'] print(result) -with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace', +with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace', engine='openpyxl') as writer: result.to_excel(writer, sheet_name='嘉兴') diff --git a/各地级市日电量模型/宁波.py b/各地级市日电量模型/宁波.py index 5494446..ff78ce9 100644 --- a/各地级市日电量模型/宁波.py +++ b/各地级市日电量模型/宁波.py @@ -81,20 +81,20 @@ import numpy as np X_eval = np.array([ - [12.9, -2.9, 0, 0, 1, 2023], - [16.4, 3.4, 0, 0, 1, 2023], - [12.8, 4.9, 0, 0, 1, 2023], - [12.9, 4.6, 0, 0, 1, 2023], - [17.9, 6.4, 0, 1, 1, 2023] + [16.0, 3.0, 0, 0, 1, 2023], + [14.8, 5.0, 0, 0, 1, 2023], + [12.8, 4.8, 0, 0, 1, 2023], + [20.9, 6.8, 0, 3, 1, 2023], + [9.5, 2.6, 0, 3, 1, 2023] ]) print(model.predict(X_eval)) result = model.predict(X_eval) -result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30']) +result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31']) result = pd.concat((result_eval['eval'], result)) result.index = result.index.map(lambda x: str(x)[:10]) result.columns = ['预测值'] print(result) -with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace', +with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace', engine='openpyxl') as writer: result.to_excel(writer, sheet_name='宁波') diff --git a/各地级市日电量模型/杭州.py b/各地级市日电量模型/杭州.py index 40aadfb..851979f 100644 --- a/各地级市日电量模型/杭州.py +++ b/各地级市日电量模型/杭州.py @@ -37,7 +37,7 @@ parent_dir = os.path.abspath(os.path.join(os.getcwd(), os.pardir)) data = pd.read_excel(os.path.join(parent_dir, '入模数据/杭州.xlsx')) data['dtdate'] = pd.to_datetime(data['dtdate'], format='%Y-%m-%d') data['year'] = data['dtdate'].dt.year -# data.index = pd.to_datetime(data.index, format='%Y-%m-%d') + data.set_index('dtdate', inplace=True) data = data.loc[normal(data['售电量']).index] @@ -58,7 +58,6 @@ data = data.loc[normal(data['售电量']).index] data['season'] = data.index.map(season) df_train = data[-180:] - df_eval = data.loc['2023-12'] print(df_train) @@ -87,20 +86,20 @@ print(result_eval) print('r2:', r2_score(y_test, y_pred)) X_eval = np.array([ - [11.8, -2.8, 0, 0, 1, 2023], - [15.1, 0.2, 0, 0, 1, 2023], - [12.9, 2.2, 0, 0, 1, 2023], - [11.4, 1.3, 0, 0, 1, 2023], - [14.8, 3.6, 0, 1, 1, 2023] + [14.9, 0.3, 0, 0, 1, 2023], + [14.3, 1.2, 0, 0, 1, 2023], + [10.6, 2.7, 0, 0, 1, 2023], + [17.2, 2.7, 0, 3, 1, 2023], + [10.7, 0.6, 0, 3, 1, 2023] ]) print(model.predict(X_eval)) result = model.predict(X_eval) -result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30']) +result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31']) result = pd.concat((result_eval['eval'], result)) result.index = result.index.map(lambda x: str(x)[:10]) result.columns = ['预测值'] print(result) -with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace', +with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace', engine='openpyxl') as writer: result.to_excel(writer, sheet_name='杭州') \ No newline at end of file diff --git a/各地级市日电量模型/温州.py b/各地级市日电量模型/温州.py index 36ceaca..68dfacf 100644 --- a/各地级市日电量模型/温州.py +++ b/各地级市日电量模型/温州.py @@ -83,20 +83,20 @@ print(result_eval) import numpy as np X_eval = np.array([ - [13.7, -0.1, 0, 0, 1, 2023], - [18.9, 3.4, 0, 0, 1, 2023], - [16.3, 11.3, 0, 0, 1, 2023], - [16.6, 9.7, 0, 0, 1, 2023], - [20.6, 20.2, 0, 1, 1, 2023] + [18, 3.3, 0, 0, 1, 2023], + [18.8, 8.2, 0, 0, 1, 2023], + [16.9, 11.2, 0, 0, 1, 2023], + [20.7, 11.6, 0, 3, 1, 2023], + [14.5, 3.3, 0, 3, 1, 2023] ]) print(model.predict(X_eval)) result = model.predict(X_eval) -result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30']) +result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31']) result = pd.concat((result_eval['eval'], result)) result.index = result.index.map(lambda x: str(x)[:10]) result.columns = ['预测值'] print(result) -with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace', +with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace', engine='openpyxl') as writer: result.to_excel(writer, sheet_name='温州') diff --git a/各地级市日电量模型/湖州.py b/各地级市日电量模型/湖州.py index 23eab02..e3e0075 100644 --- a/各地级市日电量模型/湖州.py +++ b/各地级市日电量模型/湖州.py @@ -84,20 +84,20 @@ import numpy as np X_eval = np.array([ - [9.7, -2.3, 0, 0, 1, 2023], - [13.1, 0.8, 0, 0, 1, 2023], - [10.3, 5.8, 0, 0, 1, 2023], - [10.1, 0.1, 0, 0, 1, 2023], - [12.8, 5.1, 0, 1, 1, 2023] + [12.9, 2.1, 0, 0, 1, 2023], + [11.7, 2.2, 0, 0, 1, 2023], + [8, 1.9, 0, 0, 1, 2023], + [13, 4.4, 0, 3, 1, 2023], + [9.7, 0.7, 0, 3, 1, 2023] ]) print(model.predict(X_eval)) result = model.predict(X_eval) -result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30']) +result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31']) result = pd.concat((result_eval['eval'], result)) result.index = result.index.map(lambda x: str(x)[:10]) result.columns = ['预测值'] print(result) -with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace', +with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace', engine='openpyxl') as writer: result.to_excel(writer, sheet_name='湖州') \ No newline at end of file diff --git a/各地级市日电量模型/绍兴.py b/各地级市日电量模型/绍兴.py index 0af9249..f97c39d 100644 --- a/各地级市日电量模型/绍兴.py +++ b/各地级市日电量模型/绍兴.py @@ -80,20 +80,20 @@ import numpy as np X_eval = np.array([ - [13.1, -3.5, 0, 0, 1, 2023], - [15.6, 0.1, 0, 0, 1, 2023], - [13.2, 3.6, 0, 0, 1, 2023], - [14.4, 3.2, 0, 0, 1, 2023], - [15.5, 5.3, 0, 1, 1, 2023] + [15.4, 0.1, 0, 0, 1, 2023], + [14.2, 3.5, 0, 0, 1, 2023], + [12.8, 4.6, 0, 0, 1, 2023], + [19.7, 5.2, 0, 3, 1, 2023], + [10.9, 0.8, 0, 3, 1, 2023] ]) print(model.predict(X_eval)) result = model.predict(X_eval) -result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30']) +result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31']) result = pd.concat((result_eval['eval'],result)) result.index = result.index.map(lambda x:str(x)[:10]) result.columns = ['预测值'] print(result) -with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace', +with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace', engine='openpyxl') as writer: result.to_excel(writer, sheet_name='绍兴') \ No newline at end of file diff --git a/各地级市日电量模型/舟山.py b/各地级市日电量模型/舟山.py index 3a4f6df..1df8d35 100644 --- a/各地级市日电量模型/舟山.py +++ b/各地级市日电量模型/舟山.py @@ -74,20 +74,20 @@ print(result_eval) import numpy as np X_eval = np.array([ - [11.4, 5.1, 0, 0, 1, 2023], - [15.5, 9.1, 0, 0, 1, 2023], - [11, 7.9, 0, 0, 1, 2023], - [12.7, 7.2, 0, 0, 1, 2023], - [16, 10.3, 0, 1, 1, 2023] + [15.1, 8.2, 0, 0, 1, 2023], + [12.5, 8.5, 0, 0, 1, 2023], + [12, 8.0, 0, 0, 1, 2023], + [15.0, 10.0, 0, 3, 1, 2023], + [9.3, 5.9, 0, 3, 1, 2023] ]) print(model.predict(X_eval)) result = model.predict(X_eval) -result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30']) +result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31']) result = pd.concat((result_eval['eval'], result)) result.index = result.index.map(lambda x: str(x)[:10]) result.columns = ['预测值'] print(result) -with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace', +with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace', engine='openpyxl') as writer: result.to_excel(writer, sheet_name='舟山') diff --git a/各地级市日电量模型/衢州.py b/各地级市日电量模型/衢州.py index d3c8985..d061854 100644 --- a/各地级市日电量模型/衢州.py +++ b/各地级市日电量模型/衢州.py @@ -69,21 +69,21 @@ print(result_eval) import numpy as np X_eval = np.array([ - [11.7, -0.8, 0, 0, 1, 2023], - [15.2, 3.0, 0, 0, 1, 2023], - [14.8, 5.3, 0, 0, 1, 2023], - [15.1, 5.7, 0, 0, 1, 2023], - [17.5, 7.5, 0, 1, 1, 2023] + [15.0, 3.0, 0, 0, 1, 2023], + [15.7, 5.1, 0, 0, 1, 2023], + [15.2, 5.6, 0, 0, 1, 2023], + [17.9, 6.8, 0, 3, 1, 2023], + [12.0, 2.9, 0, 3, 1, 2023] ]) print(model.predict(X_eval)) result = model.predict(X_eval) -result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30']) +result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31']) result = pd.concat((result_eval['eval'],result)) result.index = result.index.map(lambda x:str(x)[:10]) result.columns = ['预测值'] print(result) -with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace', +with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace', engine='openpyxl') as writer: result.to_excel(writer, sheet_name='衢州') diff --git a/各地级市日电量模型/金华.py b/各地级市日电量模型/金华.py index 02811ca..0a3fb16 100644 --- a/各地级市日电量模型/金华.py +++ b/各地级市日电量模型/金华.py @@ -74,20 +74,20 @@ print(result_eval) import numpy as np X_eval = np.array([ - [11.7, -0.8, 0, 0, 1], - [15.2, 3.0, 0, 0, 1], - [14.8, 5.3, 0, 0, 1], - [15.1, 5.7, 0, 0, 1], - [17.5, 7.5, 0, 1, 1] + [16.3, 2.5, 0, 0, 1], + [16.9, 3.8, 0, 0, 1], + [16.5, 6.2, 0, 0, 1], + [18.8, 7.8, 0, 3, 1], + [12.5, 2.8, 0, 3, 1] ]) print(model.predict(X_eval)) result = model.predict(X_eval) -result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30']) +result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31']) result = pd.concat((result_eval['eval'],result)) result.index = result.index.map(lambda x:str(x)[:10]) result.columns = ['预测值'] print(result) -with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace', +with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace', engine='openpyxl') as writer: result.to_excel(writer, sheet_name='金华') \ No newline at end of file diff --git a/浙江电压等级电量/分压_移动平均.py b/浙江电压等级电量/分压_移动平均.py index 6fffe55..e335f5b 100644 --- a/浙江电压等级电量/分压_移动平均.py +++ b/浙江电压等级电量/分压_移动平均.py @@ -1,6 +1,6 @@ import pandas as pd -df = pd.read_excel(r'C:\Users\鸽子\Desktop\浙江power1225.xlsx', sheet_name=1) +df = pd.read_excel(r'C:\Users\鸽子\Desktop\zj20231228.xlsx', sheet_name=1) df['pt_date'] = pd.to_datetime(df['pt_date']) # 移动平均 @@ -9,7 +9,7 @@ dict_ok = {} for city in df['city_name'].drop_duplicates(): - df_city1 = df[(df['city_name'] == city) & (df['county_name'].isnull())].set_index('pt_date').loc['2023-12'] + df_city1 = df[(df['city_name'] == city) & (df['county_name'].isnull())].set_index('pt_date').loc['2023-12'].sort_index() resut_df = pd.DataFrame({}) index_level = [] tq_list = [] @@ -21,7 +21,7 @@ for city in df['city_name'].drop_duplicates(): # index_level.append(level) df_moving_avg = pd.DataFrame(df_city1[level], index=df_city1.index) - future = pd.date_range(start='2023-12-26', periods=5, freq='D') + future = pd.date_range(start='2023-12-27', periods=5, freq='D') for date in future: df_moving_avg.loc[date, level] = df_moving_avg[-3:].mean().values @@ -38,7 +38,7 @@ for city in df['city_name'].drop_duplicates(): # index=index_level) # resut_df = pd.DataFrame({'预测电量': pred_list},index=index_level) - with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市分压电量预测_1227.xlsx', mode='a', if_sheet_exists='replace', + with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市分压电量预测_1228.xlsx', mode='a', if_sheet_exists='replace', engine='openpyxl') as writer: resut_df.to_excel(writer, sheet_name=f'{city[4:6]}') diff --git a/浙江行业电量/行业_移动平均.py b/浙江行业电量/行业_移动平均.py index 27bc756..a611ae7 100644 --- a/浙江行业电量/行业_移动平均.py +++ b/浙江行业电量/行业_移动平均.py @@ -1,14 +1,13 @@ import pandas as pd -df = pd.read_excel(r'C:\Users\鸽子\Desktop\浙江power1225.xlsx', sheet_name=2) +df = pd.read_excel(r'C:\Users\鸽子\Desktop\zj20231228.xlsx', sheet_name=2) df['stat_date'] = pd.to_datetime(df['stat_date']) # 移动平均 for city in df['city_name'].drop_duplicates(): print(city) - df_city = df[df['city_name'] == city].set_index('stat_date').loc['2023-12'] - + df_city = df[df['city_name'] == city].set_index('stat_date').loc['2023-12'].sort_index() dict_big = {} dict_ok = {} resut_df = pd.DataFrame({}) @@ -21,7 +20,7 @@ for city in df['city_name'].drop_duplicates(): for industry in df_city.columns[2:]: # index_industry.append(industry) df_moving_avg = pd.DataFrame(df_city[industry], index=df_city.index) - future = pd.date_range(start='2023-12-26', periods=5, freq='D') + future = pd.date_range(start='2023-12-27', periods=5, freq='D') for date in future: df_moving_avg.loc[date, industry] = df_moving_avg[-3:].mean().values @@ -33,7 +32,7 @@ for city in df['city_name'].drop_duplicates(): # pred_list.append(df_moving_avg[industry].sum()) # loss_list.append(df_city1[industry].sum()-df_moving_avg[industry].sum()) # rate_list.append((df_city1[industry].sum()-df_moving_avg[industry].sum())/df_city1[industry].sum()) - with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\行业电量预测_1227.xlsx', mode='a', if_sheet_exists='replace', + with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\行业电量预测_1228.xlsx', mode='a', if_sheet_exists='replace', engine='openpyxl') as writer: resut_df.to_excel(writer, sheet_name=f'{city[4:6]}')