import pandas as pd
# 读取DataFrame数据
data = {
'River Basin': ['Amazon', 'Amazon'],
'Count': [154, 154],
'2017': [10.4, 26.0],
'2018': [12.3, 27.3],
'2019': [7.1, 29.9],
'2020': [12.3, 1.3],
'2021': [5.8, 14.3],
'2022': [51.9, 1.3],
'Type': ['max', 'min']
}
df = pd.DataFrame(data)
# 按"River Basin"分组,并将同一年份的数据用连字符/连接起来
grouped_df = df.groupby('River Basin').agg(lambda x: '/'.join(map(str, x)))
# 打印结果
print(grouped_df)