{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"This notebook focuses on extracting features from event data for each player according to gamedate as per 'PITCH' or 'HIT' event. \n\n","metadata":{"papermill":{"duration":0.016773,"end_time":"2021-07-29T13:44:57.081427","exception":false,"start_time":"2021-07-29T13:44:57.064654","status":"completed"},"tags":[]}},{"cell_type":"code","source":"import numpy as np\n\n#basic declaration\nnull=np.nan;true=True;false=False\nball_weight=dict();ball_rad=dict()\nair_density=dict()\nball_weight['lb']=0.32;ball_weight['oz']=5.125;\nball_rad['ft']=0.12;ball_rad['inch']=1.45;\nair_density['mass']=0.0023\nair_density['weight']=0.075\npi=3.14;drag_coeff=0.3\ngravity=32.1740 \n\n#https://www.grc.nasa.gov/www/k-12/airplane/balldrag.html\n\ndef reduce_mem_usage(df):\n    \"\"\" iterate through all the columns of a dataframe and modify the data type\n        to reduce memory usage.        \n    \"\"\"\n    start_mem = df.memory_usage().sum() / 1024**2\n    print('Memory usage of dataframe is {:.2f} MB'.format(start_mem))\n    \n    for col in df.columns:\n        col_type = df[col].dtype\n        \n        if col_type != object:\n            c_min = df[col].min()\n            c_max = df[col].max()\n            if str(col_type)[:3] == 'int':\n                if c_min > np.iinfo(np.int8).min and c_max < np.iinfo(np.int8).max:\n                    df[col] = df[col].astype(np.int8)\n                elif c_min > np.iinfo(np.int16).min and c_max < np.iinfo(np.int16).max:\n                    df[col] = df[col].astype(np.int16)\n                elif c_min > np.iinfo(np.int32).min and c_max < np.iinfo(np.int32).max:\n                    df[col] = df[col].astype(np.int32)\n                elif c_min > np.iinfo(np.int64).min and c_max < np.iinfo(np.int64).max:\n                    df[col] = df[col].astype(np.int64)  \n            else:\n                if c_min > np.finfo(np.float16).min and c_max < np.finfo(np.float16).max:\n                    df[col] = df[col].astype(np.float16)\n                elif c_min > np.finfo(np.float32).min and c_max < np.finfo(np.float32).max:\n                    df[col] = df[col].astype(np.float32)\n                else:\n                    df[col] = df[col].astype(np.float64)\n        else:\n            df[col] = df[col].astype('category')\n\n    end_mem = df.memory_usage().sum() / 1024**2\n    print('Memory usage after optimization is: {:.2f} MB'.format(end_mem))\n    print('Decreased by {:.1f}%'.format(100 * (start_mem - end_mem) / start_mem))\n    \n    return df\n","metadata":{"papermill":{"duration":0.143651,"end_time":"2021-07-29T13:44:57.241248","exception":false,"start_time":"2021-07-29T13:44:57.097597","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-18T09:23:41.940201Z","iopub.execute_input":"2023-01-18T09:23:41.940631Z","iopub.status.idle":"2023-01-18T09:23:41.959706Z","shell.execute_reply.started":"2023-01-18T09:23:41.940598Z","shell.execute_reply":"2023-01-18T09:23:41.958313Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import warnings \nwarnings.filterwarnings('ignore')\nimport numpy as np\nimport pandas as pd\nfrom pathlib import Path\nfrom sklearn.metrics import mean_absolute_error\nfrom datetime import timedelta\nfrom functools import reduce\nfrom tqdm import tqdm\nimport lightgbm as lgbm\nimport mlb\nimport gc\nimport tensorflow as tf\nfrom tensorflow.keras.callbacks import Callback, ReduceLROnPlateau, ModelCheckpoint, EarlyStopping\npd.set_option('display.max_columns', 500)","metadata":{"papermill":{"duration":8.863102,"end_time":"2021-07-29T13:45:06.124957","exception":false,"start_time":"2021-07-29T13:44:57.261855","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-18T09:23:41.962347Z","iopub.execute_input":"2023-01-18T09:23:41.963590Z","iopub.status.idle":"2023-01-18T09:23:41.979425Z","shell.execute_reply.started":"2023-01-18T09:23:41.963545Z","shell.execute_reply":"2023-01-18T09:23:41.978652Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"players=pd.read_pickle('../input/mlb-pdef-train-dataset/playerTwitterFollowers_train.pkl')\nzz=players[['playerId','playerName']].to_dict(orient='l')\nplayer_map=dict(zip(zz['playerId'],zz['playerName']))\nplayers.head(2)\n","metadata":{"papermill":{"duration":0.120884,"end_time":"2021-07-29T13:45:06.263529","exception":false,"start_time":"2021-07-29T13:45:06.142645","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-18T09:23:41.980484Z","iopub.execute_input":"2023-01-18T09:23:41.981675Z","iopub.status.idle":"2023-01-18T09:23:42.092761Z","shell.execute_reply.started":"2023-01-18T09:23:41.981642Z","shell.execute_reply":"2023-01-18T09:23:42.091931Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train=pd.read_csv('../input/mlb-player-digital-engagement-forecasting/train.csv')\ntrain.head()","metadata":{"papermill":{"duration":85.70328,"end_time":"2021-07-29T13:46:31.982812","exception":false,"start_time":"2021-07-29T13:45:06.279532","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-18T09:23:42.093996Z","iopub.execute_input":"2023-01-18T09:23:42.095163Z","iopub.status.idle":"2023-01-18T09:25:28.995110Z","shell.execute_reply.started":"2023-01-18T09:23:42.095125Z","shell.execute_reply":"2023-01-18T09:25:28.994259Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#pitching events\nsum_cols_pitch=['is_bad_pitch','is_pitchplayed_beforehomeplate']\nmean_std_cols_pitch=['pfxX', 'pfxZ','net_pitch_acceleration','net_pitchlaunch_velocity', 'approxhorz_pitch_distance',\n               'is_pitchplayed_beforehomeplate', 'drag_force', 'magnus_force','startSpeed', 'endSpeed','nastyFactor',\\\n               'breakAngle','spinRate', 'spinDirection', 'breakY',]\n\n\ndef get_eventpitching(temp_event) -> pd.DataFrame:\n\n    all_events_pitch=pd.DataFrame()\n    \n    temp_pitcher=pd.DataFrame(columns=['playerId','date'])\n    temp_pitcher['playerId']=temp_event['pitcherId'].unique()\n    temp_pitcher['date']=temp_event['gameDate'].iloc[0]\n\n    pitchevents=temp_event[temp_event.aX.notnull()]\n    pitchevents=pitchevents.fillna(0)\n    pitchevents=get_pitchkinematics(pitchevents)\n\n    zz=get_meanstd_stats(pitchevents,mean_std_cols=mean_std_cols_pitch)\n    temp_pitcher=temp_pitcher.merge(zz,left_on='playerId',right_on='pitcherId',how='left')\n    temp_pitcher.drop(columns=['pitcherId'],inplace=True)\n    zz=get_sum_stats(pitchevents)\n    temp_pitcher=temp_pitcher.merge(zz,left_on='playerId',right_on='pitcherId',how='left')\n    temp_pitcher.drop(columns=['pitcherId'],inplace=True)\n    all_events_pitch=all_events_pitch.append(temp_pitcher)\n    \n    return all_events_pitch\n\ndef get_singleevent(event) -> pd.DataFrame:\n    return pd.DataFrame(eval(event))\n\ndef get_meanstd_stats(pitchevents,mean_std_cols) -> pd.DataFrame:\n    all_stats=pd.DataFrame(columns=['pitcherId'])\n    all_stats['pitcherId']=pitchevents.pitcherId.unique()\n    for col in mean_std_cols:\n        temp = pitchevents.groupby('pitcherId')[col].agg({'mean','std','min','max'}).reset_index().fillna(0)\n        temp.rename(columns={'mean':f'{col}_mean','std':f'{col}_std','min':f'{col}_min','max':f'{col}_max'},inplace=True)\n        all_stats=all_stats.merge(temp,on='pitcherId')\n    return all_stats\ndef get_sum_stats(pitchevents) -> pd.DataFrame:\n    all_stats=pd.DataFrame(columns=['pitcherId'])\n    all_stats['pitcherId']=pitchevents.pitcherId.unique()\n    for col in sum_cols_pitch:\n        temp = pitchevents.groupby('pitcherId')[col].agg({'sum'}).reset_index().fillna(0)\n        temp.rename(columns={'sum':f'{col}_sum'},inplace=True)\n        all_stats=all_stats.merge(temp,on='pitcherId')\n    return all_stats\n\ndef get_pitchkinematics(pitchevents) -> pd.DataFrame:\n    pitchevents['net_pitch_acceleration']=np.sqrt((pitchevents.aX.values)**2+(pitchevents.aY.values)**2+(pitchevents.aZ.values)**2)\n    pitchevents['net_pitchlaunch_velocity']=np.sqrt((pitchevents.vX0.values)**2+(pitchevents.vY0.values)**2+(pitchevents.vZ0.values)**2)\n    pitchevents['approxhorz_pitch_distance']=np.sqrt((pitchevents.x.values-pitchevents.x0.values)**2+(pitchevents.y.values-pitchevents.y0.values)**2)\n    pitchevents['is_bad_pitch']=[1 if val<0 else 0 for val in pitchevents.pZ.values]\n    pitchevents['is_pitchplayed_beforehomeplate']=[1 if val<0 else 0 for val in pitchevents.pX.values]\n    pitchevents['drag_force']=0.5*drag_coeff*pi*air_density['mass']*(ball_rad['ft']**2)*(pitchevents['net_pitchlaunch_velocity'].values**2)\n    pitchevents['magnus_force']=0.5*pi*air_density['mass']*(ball_rad['ft']**3)*(pitchevents['spinRate'].values)*(pitchevents['net_pitchlaunch_velocity'].values)\n    return pitchevents\nfor i in tqdm(range(len(train))):\n    if str(train.iloc[i]['events'])!='nan':\n        temp_event = get_singleevent(train.iloc[i]['events'])\n        all_events_pitch = get_eventpitching(temp_event)\n        \n    else:\n        continue\n        \nall_events_pitch.sample(5)","metadata":{"papermill":{"duration":831.454164,"end_time":"2021-07-29T14:00:23.453583","exception":false,"start_time":"2021-07-29T13:46:31.999419","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-18T09:25:28.997494Z","iopub.execute_input":"2023-01-18T09:25:28.998320Z","iopub.status.idle":"2023-01-18T09:38:13.102594Z","shell.execute_reply.started":"2023-01-18T09:25:28.998285Z","shell.execute_reply":"2023-01-18T09:38:13.101291Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"papermill":{"duration":0.155912,"end_time":"2021-07-29T14:00:23.763679","exception":false,"start_time":"2021-07-29T14:00:23.607767","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#*0.0174533->degree convert to rad\n# *1.467 -> MPH to ft/s\n#g=32.1740 ft/s2\n\nmean_std_cols_hit=['launchSpeed','launchAngle','max_heightreached','flighttime']\n\ndef get_eventhit(temp_event) -> pd.DataFrame:\n    \n    all_events_hit=pd.DataFrame()\n\n    temp_pitcher=pd.DataFrame(columns=['playerId','date'])\n    temp_pitcher['playerId']=temp_event['pitcherId'].unique()\n    temp_pitcher['date']=temp_event['gameDate'].iloc[0]\n\n    hitevents=temp_event[temp_event.launchSpeed.notnull()].fillna(0)\n    hitevents=get_hitkinematics(hitevents)\n\n    zz=get_meanstd_stats(hitevents,mean_std_cols=mean_std_cols_hit)\n    temp_pitcher=temp_pitcher.merge(zz,left_on='playerId',right_on='hitterId',how='left')\n    temp_pitcher.drop(columns=['hitterId'],inplace=True)\n    temp_pitcher=temp_pitcher.fillna(0)\n    all_events_hit=all_events_hit.append(temp_pitcher)\n\n    return all_events_hit\n\ndef get_meanstd_stats(hitevents,mean_std_cols) -> pd.DataFrame:\n    all_stats=pd.DataFrame(columns=['hitterId'])\n    all_stats['hitterId']=hitevents.hitterId.unique()\n    for col in mean_std_cols:\n        temp = hitevents.groupby('hitterId')[col].agg({'mean','std','min','max'}).reset_index().fillna(0)\n        temp.rename(columns={'mean':f'{col}_mean','std':f'{col}_std','min':f'{col}_min','max':f'{col}_max'},inplace=True)\n        all_stats=all_stats.merge(temp,on='hitterId')\n    return all_stats\n\ndef get_hitkinematics(hitevents) -> pd.DataFrame:\n    hitevents['max_heightreached']=((np.sin(hitevents['launchAngle'].values*0.0174533)*(hitevents['launchSpeed'].values*1.467))**2)/(2*gravity)\n    hitevents['flighttime']=2*(np.sin(hitevents['launchAngle'].values*0.0174533)*(hitevents['launchSpeed'].values*1.467))/gravity\n    return hitevents\n\n\nfor i in tqdm(range(len(train))):\n    if str(train.iloc[i]['events'])!='nan':\n        temp_event = get_singleevent(train.iloc[i]['events'])\n        all_events_hit=get_eventhit(temp_event)\n        \n    else:\n        continue\n\n        \n        \nall_events_hit.sample(5)","metadata":{"papermill":{"duration":747.450171,"end_time":"2021-07-29T14:12:51.368338","exception":false,"start_time":"2021-07-29T14:00:23.918167","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-18T09:38:13.104447Z","iopub.execute_input":"2023-01-18T09:38:13.104951Z","iopub.status.idle":"2023-01-18T09:49:31.920289Z","shell.execute_reply.started":"2023-01-18T09:38:13.104869Z","shell.execute_reply":"2023-01-18T09:49:31.919072Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def get_eventsum(temp_event) -> pd.DataFrame:\n\n    all_events_sum=pd.DataFrame()\n    temp_pitcher=pd.DataFrame(columns=['playerId','date'])\n    temp_pitcher['playerId']=temp_event['pitcherId'].unique()\n    temp_pitcher['date']=temp_event['gameDate'].iloc[0]      \n\n    zz=get_sum_stats(temp_event)\n\n    temp_pitcher=temp_pitcher.merge(zz,left_on='playerId',right_on='hitterId',how='left')\n    temp_pitcher.drop(columns=['hitterId'],inplace=True)\n    temp_pitcher=temp_pitcher.fillna(0)\n    all_events_sum=all_events_sum.append(temp_pitcher)\n    return all_events_sum\n\nsum_cols=['isGB', 'isLD', 'isFB', 'isPU','isPaOver']\n\ndef get_sum_stats(temp_event) -> pd.DataFrame:\n    all_stats=pd.DataFrame(columns=['hitterId'])\n    all_stats['hitterId']=temp_event.hitterId.unique()\n    for col in sum_cols:\n        temp = temp_event.groupby('hitterId')[col].agg({'sum'}).reset_index().fillna(0)\n        temp.rename(columns={'sum':f'{col}_sum'},inplace=True)\n        all_stats=all_stats.merge(temp,on='hitterId')\n    return all_stats\n\nfor i in tqdm(range(len(train))):\n    if str(train.iloc[i]['events'])!='nan':\n        temp_event = get_singleevent(train.iloc[i]['events'])\n        temp_event=temp_event.fillna(0)\n        all_events_sum=get_eventsum(temp_event)\n        \n        \nall_events_sum.sample(5)","metadata":{"papermill":{"duration":741.147343,"end_time":"2021-07-29T14:25:12.798039","exception":false,"start_time":"2021-07-29T14:12:51.650696","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-18T09:49:31.921696Z","iopub.execute_input":"2023-01-18T09:49:31.922019Z","iopub.status.idle":"2023-01-18T10:00:40.972631Z","shell.execute_reply.started":"2023-01-18T09:49:31.921991Z","shell.execute_reply":"2023-01-18T10:00:40.971456Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pivot_cols_pitch=['breakLength','pitchNumber','menOnBase','call']\ndef get_eventcrosstab(temp_event) -> pd.DataFrame:\n\n    all_events_crosstab=pd.DataFrame()\n\n    temp_pitcher=pd.DataFrame(columns=['playerId','date'])\n    temp_pitcher['playerId']=temp_event['pitcherId'].unique()\n    temp_pitcher['date']=temp_event['gameDate'].iloc[0]      \n\n    zz=get_crosstab_stats(temp_event)\n\n    temp_pitcher=temp_pitcher.merge(zz,left_on='playerId',right_on='pitcherId',how='left')\n    temp_pitcher.drop(columns=['pitcherId'],inplace=True)\n    temp_pitcher=temp_pitcher.fillna(0)\n    all_events_crosstab=all_events_crosstab.append(temp_pitcher)\n    return all_events_crosstab\ndef get_crosstab_stats(temp_event) -> pd.DataFrame:\n    all_stats=pd.DataFrame(columns=['pitcherId'])\n    all_stats['pitcherId']=temp_event.pitcherId.unique()\n    for col in pivot_cols_pitch:\n        zz=pd.crosstab(temp_event['pitcherId'],temp_event[col])\n        zz.columns=[f'{col}_'+str(val) for val in zz.columns]\n        all_stats=all_stats.merge(zz,on='pitcherId')\n    return all_stats\nfor i in tqdm(range(len(train))):\n    if str(train.iloc[i]['events'])!='nan':\n        temp_event = get_singleevent(train.iloc[i]['events'])\n        temp_event=temp_event.fillna(0)\n        all_events_crosstab=get_eventcrosstab(temp_event)\n        \nall_events_crosstab.sample(5)","metadata":{"papermill":{"duration":780.436376,"end_time":"2021-07-29T14:38:13.634080","exception":false,"start_time":"2021-07-29T14:25:13.197704","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-18T10:00:40.974509Z","iopub.execute_input":"2023-01-18T10:00:40.974861Z","iopub.status.idle":"2023-01-18T10:12:01.256248Z","shell.execute_reply.started":"2023-01-18T10:00:40.974829Z","shell.execute_reply":"2023-01-18T10:12:01.255023Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"standings=pd.read_pickle('../input/mlb-pdef-train-dataset/standings_train.pkl')\n\nfor cols in ['divisionChamp','divisionLeader','wildCardLeader']:\n    standings[cols]=standings[cols].fillna(False)\n","metadata":{"papermill":{"duration":0.664166,"end_time":"2021-07-29T14:38:14.857177","exception":false,"start_time":"2021-07-29T14:38:14.193011","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-18T10:12:01.257870Z","iopub.execute_input":"2023-01-18T10:12:01.258203Z","iopub.status.idle":"2023-01-18T10:12:01.347512Z","shell.execute_reply.started":"2023-01-18T10:12:01.258173Z","shell.execute_reply":"2023-01-18T10:12:01.346364Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"all_teamids=standings.teamId.unique()\nzz=standings[standings.teamId==all_teamids[10]]","metadata":{"papermill":{"duration":0.553111,"end_time":"2021-07-29T14:38:15.970720","exception":false,"start_time":"2021-07-29T14:38:15.417609","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-18T10:12:01.349139Z","iopub.execute_input":"2023-01-18T10:12:01.349477Z","iopub.status.idle":"2023-01-18T10:12:01.364243Z","shell.execute_reply.started":"2023-01-18T10:12:01.349446Z","shell.execute_reply":"2023-01-18T10:12:01.363050Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"crosstab_cols=['streakCode','divisionRank', 'leagueRank', 'wildCardRank','divisionChamp', 'divisionLeader','wildCardLeader']\nnormal_cols=[ 'leagueGamesBack','sportGamesBack', 'divisionGamesBack', 'wins', 'losses', 'pct',\\\n               'runsAllowed', 'runsScored']+list(standings.columns[20:-2])\ndef get_single_team(zz,crosstab_cols) -> pd.DataFrame:\n    cols2_drop=[f'wildCardRank_{val}' for val in np.arange(6,12)]+[f'leagueRank_{val}' for val in np.arange(6,16)]    \n    temp_feat=pd.DataFrame()\n    temp_feat['teamId']=zz['teamId']\n    temp_feat['gameDate']=zz['gameDate']\n    for cols in crosstab_cols:\n        temp=pd.crosstab(zz.gameDate,zz[cols])\n        temp.columns=[f'{cols}_{val}' for val in temp.columns]   \n        try:\n\n            if cols == 'wildCardRank':\n                temp=temp[[f'wildCardRank_{val}' for val in np.arange(1,6)]]\n            if cols == 'leagueRank':\n                temp=temp[[f'leagueRank_{val}' for val in np.arange(1,6)]]\n        except:\n            continue\n        temp_feat=temp_feat.merge(temp,on='gameDate',how='left')\n    return temp_feat","metadata":{"papermill":{"duration":0.553438,"end_time":"2021-07-29T14:38:17.072657","exception":false,"start_time":"2021-07-29T14:38:16.519219","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-18T10:12:01.365757Z","iopub.execute_input":"2023-01-18T10:12:01.366142Z","iopub.status.idle":"2023-01-18T10:12:01.376836Z","shell.execute_reply.started":"2023-01-18T10:12:01.366108Z","shell.execute_reply":"2023-01-18T10:12:01.375680Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"zz=standings[standings.teamId==all_teamids[0]].reset_index(drop=True)\ntemp_feat=get_single_team(zz,crosstab_cols)\nfeat_cols=temp_feat.columns\n\ndef get_standing_feats(standings,crosstab_cols,normal_cols) -> pd.DataFrame:\n    standing_data=pd.DataFrame(columns=feat_cols)\n    \n    all_teamids=standings.teamId.unique()\n    for ids in tqdm(all_teamids):\n        zz=standings[standings.teamId==ids].reset_index(drop=True)\n        temp_feat=get_single_team(zz,crosstab_cols)\n        #print(temp_feat.shape,zz.shape)\n        for cols in normal_cols:\n            temp_feat[cols]=zz[cols]\n        standing_data=standing_data.append(temp_feat)\n        \n    return standing_data","metadata":{"papermill":{"duration":0.75963,"end_time":"2021-07-29T14:38:18.365128","exception":false,"start_time":"2021-07-29T14:38:17.605498","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-18T10:12:01.378343Z","iopub.execute_input":"2023-01-18T10:12:01.379425Z","iopub.status.idle":"2023-01-18T10:12:01.513818Z","shell.execute_reply.started":"2023-01-18T10:12:01.379382Z","shell.execute_reply":"2023-01-18T10:12:01.512823Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nstanding_data=get_standing_feats(standings,crosstab_cols=crosstab_cols,normal_cols=normal_cols)\nstanding_data","metadata":{"papermill":{"duration":7.796159,"end_time":"2021-07-29T14:38:26.698306","exception":false,"start_time":"2021-07-29T14:38:18.902147","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-18T10:12:01.515105Z","iopub.execute_input":"2023-01-18T10:12:01.516016Z","iopub.status.idle":"2023-01-18T10:12:06.138009Z","shell.execute_reply.started":"2023-01-18T10:12:01.515982Z","shell.execute_reply":"2023-01-18T10:12:06.136866Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"standing_data=standing_data.fillna(0)\nstanding_data.to_csv('submit_data.csv',index=None)","metadata":{"papermill":{"duration":1.632046,"end_time":"2021-07-29T14:38:28.895412","exception":false,"start_time":"2021-07-29T14:38:27.263366","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-18T10:12:06.142600Z","iopub.execute_input":"2023-01-18T10:12:06.143408Z","iopub.status.idle":"2023-01-18T10:12:06.810990Z","shell.execute_reply.started":"2023-01-18T10:12:06.143359Z","shell.execute_reply":"2023-01-18T10:12:06.810032Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"standing_data.isna().sum()[:49]","metadata":{"papermill":{"duration":0.595065,"end_time":"2021-07-29T14:38:30.088856","exception":false,"start_time":"2021-07-29T14:38:29.493791","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-18T10:12:06.812254Z","iopub.execute_input":"2023-01-18T10:12:06.812610Z","iopub.status.idle":"2023-01-18T10:12:06.837036Z","shell.execute_reply.started":"2023-01-18T10:12:06.812579Z","shell.execute_reply":"2023-01-18T10:12:06.835789Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"papermill":{"duration":0.569494,"end_time":"2021-07-29T14:38:31.221059","exception":false,"start_time":"2021-07-29T14:38:30.651565","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"papermill":{"duration":0.561655,"end_time":"2021-07-29T14:38:32.347539","exception":false,"start_time":"2021-07-29T14:38:31.785884","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]}]}