水文预报 求各个年份的纳什效率系数

import pandas as pd

file_path = r'C:\Users\Admin\Desktop\实测流量.xlsx'
df = pd.read_excel(file_path, sheet_name=0)

# 按年份进行分组
groups = df.groupby('年份')


# 计算纳什效率系数
for year, group in groups:
    true_values = group['实测流量']
    predicted_values = group['预报流量']
    mean_true = true_values.mean()
    nse = 1 - (np.sum((predicted_values - true_values)**2) / np.sum((true_values - mean_true)**2))
    print(f"Nash-Sutcliffe Efficiency for {year}: {nse:.2f}")

 

你可能感兴趣的:(python,pandas,开发语言)