-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plot_Rating.py
32 lines (25 loc) · 1.14 KB
/
Plot_Rating.py
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
29
30
31
32
import pandas as pd
import matplotlib.pyplot as plt
# Specify the sheet names containing the data
sheet_names = ["Data", "DEF", "MID", "OFF"]
# Create subplots for each scatter plot
fig, axs = plt.subplots(nrows=2, ncols=2, figsize=(12, 8))
# Iterate over each sheet and create scatter plot
for idx, sheet_name in enumerate(sheet_names):
# Read the DataFrame for the current sheet
df = pd.read_excel("Data.xlsx", sheet_name=sheet_name)
# Convert 'Rating' and 'Fifa Ability Overall' columns to numeric, ignoring errors
df['Rating'] = pd.to_numeric(df['Rating'], errors='coerce')
df['Fifa Ability Overall'] = pd.to_numeric(df['Fifa Ability Overall'], errors='coerce')
# Drop rows with NaN values in either column
df = df.dropna(subset=['Rating', 'Fifa Ability Overall'])
# Plot the scatter plot for 'Rating' vs 'Fifa Ability Overall'
row = idx // 2
col = idx % 2
axs[row, col].scatter(df['Rating'], df['Fifa Ability Overall'])
axs[row, col].set_title(sheet_name)
axs[row, col].set_xlabel('Rating')
axs[row, col].set_ylabel('Fifa Ability Overall')
# Adjust layout
plt.tight_layout()
plt.show()