-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFreeAgentClass.py
More file actions
28 lines (22 loc) · 943 Bytes
/
FreeAgentClass.py
File metadata and controls
28 lines (22 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Imports
import pandas as pd
# Your File Path
file_path = 'Files/Madden26/IE/Season1/Player.xlsx'
# Read the Excel file
df = pd.read_excel(file_path)
# Filter for players with ContractStatus = 'Expiring' or 'FreeAgent'
contract_filter = df['ContractStatus'].isin(['Expiring', 'FreeAgent'])
filtered_df = df[contract_filter]
# Sort by OverallRating descending and get top 10 per position
top_10_per_position = (
filtered_df.sort_values(by='OverallRating', ascending=False)
.groupby('Position')
.head(10)
.reset_index(drop=True)
)
# Select only the specified columns in the desired order
selected_columns = ['Position', 'OverallRating', 'FirstName', 'LastName', 'ContractStatus', 'Age', 'YearsPro']
top_10_per_position = top_10_per_position[selected_columns]
# Save the result to Excel
output_filename = 'Player_FreeAgentClass.xlsx'
top_10_per_position.to_excel(f'Files/Madden26/IE/Season1/{output_filename}', index=False)