Spaces:
Paused
Paused
Update df_update.py
Browse files- df_update.py +6 -6
df_update.py
CHANGED
|
@@ -160,7 +160,7 @@ class df_update:
|
|
| 160 |
|
| 161 |
|
| 162 |
df = df.with_columns([
|
| 163 |
-
pl.when(pl.col('in_zone').is_null()).then(pl.col('in_zone_predict')).otherwise(pl.col('in_zone')).alias('
|
| 164 |
|
| 165 |
])
|
| 166 |
|
|
@@ -169,11 +169,11 @@ class df_update:
|
|
| 169 |
df = df.with_columns([
|
| 170 |
pl.when(df['launch_speed'].is_null()).then(None).otherwise(df['barrel']).alias('barrel'),
|
| 171 |
pl.lit('average').alias('average'),
|
| 172 |
-
pl.when(pl.col('
|
| 173 |
-
pl.when((pl.col('
|
| 174 |
-
pl.when((pl.col('
|
| 175 |
-
pl.when((pl.col('
|
| 176 |
-
pl.when((pl.col('
|
| 177 |
pl.when(pl.col('event_type').str.contains('strikeout')).then(True).otherwise(False).alias('k'),
|
| 178 |
pl.when(pl.col('event_type').is_in(['walk', 'intent_walk'])).then(True).otherwise(False).alias('bb'),
|
| 179 |
pl.when(pl.col('attack_zone').is_null()).then(pl.col('attack_zone_predict')).otherwise(pl.col('attack_zone')).alias('attack_zone_final'),
|
|
|
|
| 160 |
|
| 161 |
|
| 162 |
df = df.with_columns([
|
| 163 |
+
pl.when(pl.col('in_zone').is_null()).then(pl.col('in_zone_predict')).otherwise(pl.col('in_zone')).alias('in_zone'),
|
| 164 |
|
| 165 |
])
|
| 166 |
|
|
|
|
| 169 |
df = df.with_columns([
|
| 170 |
pl.when(df['launch_speed'].is_null()).then(None).otherwise(df['barrel']).alias('barrel'),
|
| 171 |
pl.lit('average').alias('average'),
|
| 172 |
+
pl.when(pl.col('in_zone') == False).then(True).otherwise(False).alias('out_zone'),
|
| 173 |
+
pl.when((pl.col('in_zone') == True) & (pl.col('swings') == 1)).then(True).otherwise(False).alias('zone_swing'),
|
| 174 |
+
pl.when((pl.col('in_zone') == True) & (pl.col('swings') == 1) & (pl.col('whiffs') == 0)).then(True).otherwise(False).alias('zone_contact'),
|
| 175 |
+
pl.when((pl.col('in_zone') == False) & (pl.col('swings') == 1)).then(True).otherwise(False).alias('ozone_swing'),
|
| 176 |
+
pl.when((pl.col('in_zone') == False) & (pl.col('swings') == 1) & (pl.col('whiffs') == 0)).then(True).otherwise(False).alias('ozone_contact'),
|
| 177 |
pl.when(pl.col('event_type').str.contains('strikeout')).then(True).otherwise(False).alias('k'),
|
| 178 |
pl.when(pl.col('event_type').is_in(['walk', 'intent_walk'])).then(True).otherwise(False).alias('bb'),
|
| 179 |
pl.when(pl.col('attack_zone').is_null()).then(pl.col('attack_zone_predict')).otherwise(pl.col('attack_zone')).alias('attack_zone_final'),
|