Adding support for custom card creation
This commit is contained in:
parent
9182556e44
commit
63b5487c44
@ -72,20 +72,20 @@ async def main(args):
|
||||
start_time = datetime.datetime.now()
|
||||
release_directory = f'{start_time.year}-{start_time.month}-{start_time.day}'
|
||||
|
||||
data = await batters.creation.run_batters(
|
||||
cardset, input_path, post_players, CARD_BASE_URL, release_directory, player_description, season_pct,
|
||||
post_batters, pull_fielding, season, is_liveseries, ignore_limits, is_custom
|
||||
)
|
||||
# data = await batters.creation.run_batters(
|
||||
# cardset, input_path, post_players, CARD_BASE_URL, release_directory, player_description, season_pct,
|
||||
# post_batters, pull_fielding, season, is_liveseries, ignore_limits, is_custom
|
||||
# )
|
||||
|
||||
print(f'Batter updates are complete')
|
||||
start_time_two = datetime.datetime.now()
|
||||
run_time = start_time_two - start_time
|
||||
print(f'Total batting cards: {data["tot_batters"]}\nNew cardset batters: {data["new_batters"]}\n'
|
||||
f'Batter runtime: {round(run_time.total_seconds())} seconds\n')
|
||||
# print(f'Total batting cards: {data["tot_batters"]}\nNew cardset batters: {data["new_batters"]}\n'
|
||||
# f'Batter runtime: {round(run_time.total_seconds())} seconds\n')
|
||||
|
||||
data = await pitchers.creation.run_pitchers(
|
||||
cardset, input_path, CARD_BASE_URL, season, release_directory, player_description, season_pct, post_players,
|
||||
post_pitchers, is_liveseries, ignore_limits, pull_fielding
|
||||
post_pitchers, is_liveseries, ignore_limits, pull_fielding, is_custom
|
||||
)
|
||||
pitching_stats = data['pitching_stats']
|
||||
|
||||
|
||||
10
data-input/Backyard Baseball Cardset/vlhh-basic.csv
Normal file
10
data-input/Backyard Baseball Cardset/vlhh-basic.csv
Normal file
@ -0,0 +1,10 @@
|
||||
Season,Name,Tm,G,TBF,ERA,H,2B,3B,R,ER,HR,BB,IBB,HBP,SO,AVG,OBP,SLG,wOBA,playerId
|
||||
2018,Amir Khan,COL,67,139,3.34020619,20,1,0,14,12,2,21,5,3,45,0.178571428,0.318840579,0.241071428,0.251533477378071,999942002
|
||||
2018,Kenny Kawaguchi ,HOU,32,389,2.07692308,56,14,1,27,23,7,38,0,3,160,0.16184971,0.25,0.268786127,0.235882954499156,999942013
|
||||
2018,Angela Delvecchio,NYY,32,351,3.87250996,81,19,2,38,36,6,27,0,1,102,0.252336448,0.311428571,0.380062305,0.302490902798516,999942003
|
||||
2018,Gretchen Hasselhoff ,DET,28,155,5.94915254,31,8,0,26,26,6,6,0,3,41,0.215277777,0.258064516,0.395833333,0.280083190625714,999942010
|
||||
2018,Billy Jean Blackwood,TBR,57,102,4.43835616,21,1,0,12,12,4,10,0,2,24,0.238636363,0.326732673,0.386363636,0.314640853664663,999942006
|
||||
2018,Ernie Steele,KCR,22,250,3.56896552,58,14,2,24,23,7,22,2,0,59,0.256637168,0.32128514,0.429203539,0.321491109938757,999942009
|
||||
2018,Lisa Crocket,LAA,7,60,1.84090909,10,3,0,3,3,1,8,0,0,18,0.192307692,0.3,0.307692307,0.276101237535477,999942016
|
||||
2018,Luanne Lui,TOR,63,127,2.78350515,25,7,0,10,10,3,6,0,1,35,0.210084033,0.251968503,0.344537815,0.258848212366029,999942017
|
||||
2018,Sally Dobbs,DET,49,100,5.01428572,25,5,0,14,13,6,5,1,1,22,0.268817204,0.313131313,0.516129032,0.349112946159986,999942026
|
||||
|
10
data-input/Backyard Baseball Cardset/vlhh-rate.csv
Normal file
10
data-input/Backyard Baseball Cardset/vlhh-rate.csv
Normal file
@ -0,0 +1,10 @@
|
||||
Season,Name,Tm,IP,TBF,GB/FB,LD%,GB%,FB%,IFFB%,HR/FB,IFH%,BUH%,Pull%,Cent%,Oppo%,Soft%,Med%,Hard%,playerId
|
||||
2018,Amir Khan,COL,32.1,139,1.333333333,0.176470588,0.470588235,0.352941176,0.041666666,0.083333333,0.0625,0.5,0.41428571,0.27142857,0.31428571,0.12857143,0.51428571,0.35714286,999942002
|
||||
2018,Kenny Kawaguchi ,HOU,99.2,389,0.712643678,0.190217391,0.336956521,0.472826086,0.103448275,0.08045977,0.048387096,0.25,0.34042553,0.33510638,0.32446809,0.15957447,0.56382979,0.27659574,999942013
|
||||
2018,Angela Delvecchio,NYY,83.2,351,1.444444444,0.296803652,0.415525114,0.287671232,0.047619047,0.095238095,0.021978021,0,0.36651584,0.3800905,0.25339367,0.14027149,0.4841629,0.37556561,999942003
|
||||
2018,Gretchen Hasselhoff ,DET,39.1,155,0.64,0.219047619,0.304761904,0.476190476,0.14,0.12,0.03125,0,0.41904762,0.36190476,0.21904762,0.19047619,0.39047619,0.41904762,999942010
|
||||
2018,Billy Jean Blackwood,TBR,24.1,102,1.38095238,0.23076923,0.446153846,0.323076923,0.142857142,0.19047619,0.137931034,0,0.46969697,0.34848485,0.18181818,0.13636364,0.51515152,0.34848485,999942006
|
||||
2018,Ernie Steele,KCR,58,250,0.592105263,0.275449101,0.269461077,0.45508982,0.078947368,0.092105263,0.066666666,0,0.44378698,0.27810651,0.27810651,0.15976331,0.43195266,0.40828402,999942009
|
||||
2018,Lisa Crocket,LAA,14.2,60,0.857142857,0.235294117,0.352941176,0.411764705,0,0.071428571,0,0,0.35294118,0.47058824,0.17647059,0.02941176,0.5,0.47058824,999942016
|
||||
2018,Luanne Lui,TOR,32.1,127,0.38,0.188235294,0.223529411,0.588235294,0.1,0.06,0,0,0.32941176,0.32941176,0.34117647,0.17647059,0.6,0.22352941,999942017
|
||||
2018,Sally Dobbs,DET,23.1,100,1.478260869,0.197183098,0.478873239,0.323943661,0.04347826,0.260869565,0.088235294,0,0.45833333,0.30555556,0.23611111,0.15277778,0.33333333,0.51388889,999942026
|
||||
|
10
data-input/Backyard Baseball Cardset/vrhh-basic.csv
Normal file
10
data-input/Backyard Baseball Cardset/vrhh-basic.csv
Normal file
@ -0,0 +1,10 @@
|
||||
Season,Name,Tm,G,TBF,ERA,H,2B,3B,R,ER,HR,BB,IBB,HBP,SO,AVG,OBP,SLG,wOBA,playerId
|
||||
2018,Amir Khan,COL,69,170,1.78676471,21,5,0,11,9,3,15,0,3,67,0.141891891,0.23076923,0.236486486,0.214593064855542,999942002
|
||||
2018,Kenny Kawaguchi ,HOU,32,410,3.66556291,87,22,1,41,41,12,26,0,4,116,0.23076923,0.286063569,0.389920424,0.293233008722804,999942013
|
||||
2018,Angela Delvecchio,NYY,32,429,3.00928793,92,20,1,38,36,13,19,0,4,118,0.227160493,0.268065268,0.377777777,0.279531600175204,999942003
|
||||
2018,Gretchen Hasselhoff ,DET,31,554,3.91603053,115,25,1,61,57,21,45,0,8,118,0.232323232,0.304347826,0.414141414,0.311604773760706,999942010
|
||||
2018,Billy Jean Blackwood,TBR,69,182,3.97674419,44,6,0,19,19,7,10,0,0,51,0.260355029,0.3,0.420118343,0.310334428482585,999942006
|
||||
2018,Ernie Steele,KCR,22,268,5.69189189,67,12,0,42,39,13,18,0,1,46,0.273469387,0.324528301,0.481632653,0.345056856353328,999942009
|
||||
2018,Lisa Crocket,LAA,7,70,7.71428572,19,5,0,14,14,2,2,0,1,15,0.283582089,0.314285714,0.447761194,0.327880488123212,999942016
|
||||
2018,Luanne Lui,TOR,69,158,4.4587156,32,7,0,19,18,10,17,0,1,50,0.233576642,0.32051282,0.503649635,0.350476588958349,999942017
|
||||
2018,Sally Dobbs,DET,53,145,2.34782609,25,2,1,10,10,2,10,1,1,21,0.190839694,0.25,0.267175572,0.228328721089797,999942026
|
||||
|
10
data-input/Backyard Baseball Cardset/vrhh-rate.csv
Normal file
10
data-input/Backyard Baseball Cardset/vrhh-rate.csv
Normal file
@ -0,0 +1,10 @@
|
||||
Season,Name,Tm,IP,TBF,GB/FB,LD%,GB%,FB%,IFFB%,HR/FB,IFH%,BUH%,Pull%,Cent%,Oppo%,Soft%,Med%,Hard%,playerId
|
||||
2018,Amir Khan,COL,45.1,170,0.970588235,0.192771084,0.397590361,0.409638554,0.147058823,0.088235294,0.06060606,1,0.35714286,0.32142857,0.32142857,0.26190476,0.57142857,0.16666667,999942002
|
||||
2018,Kenny Kawaguchi ,HOU,100.2,410,0.95145631,0.229885057,0.375478927,0.394636015,0.13592233,0.116504854,0.071428571,0.333333333,0.33712121,0.43560606,0.22727273,0.20454545,0.46212121,0.33333333,999942013
|
||||
2018,Angela Delvecchio,NYY,107.2,429,1.125,0.229965156,0.407665505,0.362369337,0.134615384,0.125,0.059829059,1,0.34722222,0.34027778,0.3125,0.23611111,0.43055556,0.33333333,999942003
|
||||
2018,Gretchen Hasselhoff ,DET,131,554,0.565445026,0.208994708,0.285714285,0.505291005,0.094240837,0.109947643,0.055555555,0.6,0.43342037,0.30548303,0.26109661,0.19321149,0.44386423,0.36292428,999942010
|
||||
2018,Billy Jean Blackwood,TBR,43,182,0.633333333,0.176470588,0.319327731,0.50420168,0.133333333,0.116666666,0.184210526,0,0.44166667,0.39166667,0.16666667,0.24166667,0.38333333,0.375,999942006
|
||||
2018,Ernie Steele,KCR,61.2,268,0.761904761,0.252525252,0.323232323,0.424242424,0.107142857,0.154761904,0.0625,0.2,0.33004926,0.33497537,0.33497537,0.17241379,0.44334975,0.38423645,999942009
|
||||
2018,Lisa Crocket,LAA,16.1,70,1.666666666,0.215686274,0.490196078,0.294117647,0,0.133333333,0.16,1,0.53846154,0.28846154,0.17307692,0.11538462,0.36538462,0.51923077,999942016
|
||||
2018,Luanne Lui,TOR,36.1,158,0.259259259,0.218390804,0.16091954,0.620689655,0.222222222,0.185185185,0.071428571,0.333333333,0.36666667,0.33333333,0.3,0.28888889,0.31111111,0.4,999942017
|
||||
2018,Sally Dobbs,DET,38.1,145,1.696969696,0.205357142,0.5,0.294642857,0.121212121,0.06060606,0.053571428,0,0.34513274,0.4159292,0.23893805,0.27433628,0.46017699,0.26548673,999942026
|
||||
|
@ -10,7 +10,7 @@ master_debug = True
|
||||
alt_database = False
|
||||
|
||||
if alt_database == 'dev':
|
||||
DB_URL = 'https://pddev.manticorum.com/api'
|
||||
DB_URL = 'https://pd.manticorum.com/api'
|
||||
|
||||
|
||||
def param_char(other_params):
|
||||
|
||||
@ -87,9 +87,10 @@ async def pd_pitchingcardratings_df(cardset_id: int):
|
||||
return ratings
|
||||
|
||||
|
||||
def match_player_lines(all_pitching: pd.DataFrame, all_players: pd.DataFrame, df_p: pd.DataFrame):
|
||||
def match_player_lines(
|
||||
all_pitching: pd.DataFrame, all_players: pd.DataFrame, df_p: pd.DataFrame, is_custom: bool = False):
|
||||
def get_pids(df_data):
|
||||
return get_all_pybaseball_ids([df_data["playerId"]], 'fangraphs')
|
||||
return get_all_pybaseball_ids([df_data["playerId"]], 'fangraphs', is_custom)
|
||||
|
||||
print(f'Now pulling mlbam player IDs...')
|
||||
ids_and_names = all_pitching.apply(get_pids, axis=1)
|
||||
@ -473,7 +474,7 @@ async def post_player_updates(
|
||||
async def run_pitchers(
|
||||
cardset: dict, input_path: str, card_base_url: str, season: int, release_directory: str,
|
||||
player_description: str, season_pct: float, post_players: bool, post_pitchers: bool, is_liveseries: bool,
|
||||
ignore_limits: bool):
|
||||
ignore_limits: bool, pull_fielding: bool = True, is_custom: bool = False):
|
||||
print(f'Pulling PD player IDs...')
|
||||
pd_players = await pd_players_df(cardset['id'])
|
||||
|
||||
@ -481,9 +482,12 @@ async def run_pitchers(
|
||||
print(f'Processed {len(all_stats.values)} pitchers\n')
|
||||
|
||||
print(f'Pulling pitcher defense...')
|
||||
if pull_fielding:
|
||||
df_p = cde.get_bbref_fielding_df('p', season)
|
||||
else:
|
||||
df_p = pd.DataFrame()
|
||||
|
||||
pit_step1 = match_player_lines(all_stats, pd_players, df_p)
|
||||
pit_step1 = match_player_lines(all_stats, pd_players, df_p, is_custom)
|
||||
if post_players:
|
||||
new_pitchers = await create_new_players(
|
||||
pit_step1, cardset, card_base_url, release_directory, player_description
|
||||
|
||||
Loading…
Reference in New Issue
Block a user