在Pandas和Pysimplegui中,可以通过以下步骤找到最高和最低值,并将它们聚合成字符串:
import pandas as pd
import PySimpleGUI as sg
data = {'Name': ['John', 'Emma', 'Ryan', 'Emily'],
'Age': [25, 30, 35, 28],
'Salary': [50000, 60000, 45000, 55000]}
df = pd.DataFrame(data)
max_salary = df['Salary'].max()
min_salary = df['Salary'].min()
result = f"最高薪资:{max_salary},最低薪资:{min_salary}"
layout = [[sg.Text(result)]]
window = sg.Window('薪资统计', layout)
event, values = window.read()
window.close()
完整的代码示例如下:
import pandas as pd
import PySimpleGUI as sg
data = {'Name': ['John', 'Emma', 'Ryan', 'Emily'],
'Age': [25, 30, 35, 28],
'Salary': [50000, 60000, 45000, 55000]}
df = pd.DataFrame(data)
max_salary = df['Salary'].max()
min_salary = df['Salary'].min()
result = f"最高薪资:{max_salary},最低薪资:{min_salary}"
layout = [[sg.Text(result)]]
window = sg.Window('薪资统计', layout)
event, values = window.read()
window.close()
这段代码将创建一个简单的GUI窗口,显示最高和最低薪资的结果。你可以根据实际需求修改数据和GUI窗口的布局。
领取专属 10元无门槛券
手把手带您无忧上云