The problem can be formulated as a binary integer program (IP) and can be solved using scipy.optimize.linprog with integrality constraint:
from scipy.optimize import linprog
# Players for 5 slots / positions are needed
# the data provided was insufficient, leading to infeasible solution
# adding a few dummy players (use players from real data instead)
# max value of the objective will depend on the dummy player scores here
# so replace them with real data
# data # variables
# juan-soto 30.3773 ['OF'] # x1
# kyle-tucker 44.0626 ['OF'] # x2
# yordan-alvarez 32.510200000000005 ['CI', 'OF'] # x3
# william-contreras 26.7904 ['CI', 'MI'] # x4
# dummy1 16.7904 ['OF', 'MI'] # x5
# dummy2 22.7904 ['CI', 'MI'] # x6
# dummy3 32.7904 ['CI', 'OF', 'MI'] # x7
# IP formulation
# objective
# max(30.3773*x1 + 44.0626*x2 + 32.510200000000005*x3 + 26.7904*x4 +
# 16.7904*x5 + 22.7904*x6 + 32.7904*x7)
# constraints
# 0*x1 + 0*x2 + 1*x3 + 1*x4 + 0*x5 + 1*x6 + 1*x7 >= 1 # CI >= 1
# 0*x1 + 0*x2 + 0*x3 + 1*x4 + 1*x5 + 1*x6 + 1*x7 >= 1 # MI >= 1
# 1*x1 + 1*x2 + 1*x3 + 0*x4 + 1*x5 + 0*x6 + 1*x7 >= 1 # OF >= 1
# x1 + x2 + x3 + x4 + x5 + x6 + x7 = 5 # POS: #hitters = # positions= 5
# x1, x2, x3, x4, x5, x6, x7 in {0,1} # integers
# implementation
c = np.array([30.3773, 44.0626, 32.510200000000005, 26.7904, 16.7904, 22.7904, 32.7904])
A = np.array([[0, 0, 1, 1, 0, 1, 1], # CI
[0, 0, 0, 1, 1, 1, 1], # MI
[1, 1, 1, 0, 1, 0, 1], # OF
[1, 1, 1, 1, 1, 1, 1]] # POS
)
b = np.array([1, 1, 1, 5])
res = linprog(-c, A_ub=-A[:3,:], A_eq=A[3:,:], b_ub=-b[:3], b_eq=b[3:], bounds=[(0,1)]*7, integrality=[1]*7) # need to formulate as a minimization problem
print(-res.fun, res.x, res.message)
# 166.5309 [ 1. 1. 1. 1. 0. -0. 1.] Optimization terminated successfully. (HiGHS Status 7: Optimal)
As it can be seen, the optimal solution is x1=x2=x3=x4=x7=1, with optimal hitting (projection) score 166.5309, i.e., it is optimal to select 1st, 2nd, 3rd, 4th and 7th hitters to maximize the hitting score.