adding invalidoperationerror
This commit is contained in:
@@ -32,7 +32,10 @@ import zipfile
|
|||||||
import os
|
import os
|
||||||
from rowers.models import strokedatafields
|
from rowers.models import strokedatafields
|
||||||
import polars as pl
|
import polars as pl
|
||||||
from polars.exceptions import ColumnNotFoundError, SchemaError
|
from polars.exceptions import (
|
||||||
|
ColumnNotFoundError, SchemaError, ComputeError,
|
||||||
|
InvalidOperationError
|
||||||
|
)
|
||||||
|
|
||||||
from rowingdata import (
|
from rowingdata import (
|
||||||
KinoMapParser,
|
KinoMapParser,
|
||||||
@@ -689,29 +692,29 @@ def clean_df_stats_pl(datadf, workstrokesonly=True, ignorehr=True,
|
|||||||
return datadf
|
return datadf
|
||||||
try:
|
try:
|
||||||
datadf = datadf.with_columns((-pl.col('catch')).alias('catch'))
|
datadf = datadf.with_columns((-pl.col('catch')).alias('catch'))
|
||||||
except (KeyError, TypeError):
|
except (KeyError, TypeError, InvalidOperationError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
datadf = datadf.with_columns((pl.col('peakforceangle')+1000).alias('peakforceangle'))
|
datadf = datadf.with_columns((pl.col('peakforceangle')+1000).alias('peakforceangle'))
|
||||||
except (KeyError, TypeError):
|
except (KeyError, TypeError, InvalidOperationError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
datadf = datadf.with_columns((pl.col('hr')+10).alias('hr'))
|
datadf = datadf.with_columns((pl.col('hr')+10).alias('hr'))
|
||||||
except (KeyError, TypeError):
|
except (KeyError, TypeError, InvalidOperationError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# protect 0 spm values from being nulled
|
# protect 0 spm values from being nulled
|
||||||
try:
|
try:
|
||||||
datadf = datadf.with_columns((pl.col('spm')+1.0).alias('spm'))
|
datadf = datadf.with_columns((pl.col('spm')+1.0).alias('spm'))
|
||||||
except (KeyError, TypeError):
|
except (KeyError, TypeError, InvalidOperationError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# protect 0 workoutstate values from being nulled
|
# protect 0 workoutstate values from being nulled
|
||||||
try:
|
try:
|
||||||
datadf = datadf.with_columns((pl.col('workoutstate')+1).alias('workoutstate'))
|
datadf = datadf.with_columns((pl.col('workoutstate')+1).alias('workoutstate'))
|
||||||
except (KeyError, TypeError):
|
except (KeyError, TypeError, InvalidOperationError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -2028,16 +2031,28 @@ def dataplep(rowdatadf, id=0, inboard=0.88, forceunit='lbs', bands=True, barchar
|
|||||||
if windowsize <= 3:
|
if windowsize <= 3:
|
||||||
windowsize = 5
|
windowsize = 5
|
||||||
|
|
||||||
df.with_columns(
|
try:
|
||||||
(pl.col(" Cadence (stokes/min)").map_batches(lambda x: savgol_filter(x.to_numpy(), windowsize, 3)).explode()
|
df.with_columns(
|
||||||
).alias(" Cadence (stokes/min)"))
|
(pl.col(" Cadence (stokes/min)").map_batches(lambda x: savgol_filter(x.to_numpy(), windowsize, 3)).explode()
|
||||||
df.with_columns(
|
).alias(" Cadence (stokes/min)"))
|
||||||
(pl.col(" DriveLength (meters)").map_batches(lambda x: savgol_filter(x.to_numpy(), windowsize, 3)).explode()
|
except ComputeError:
|
||||||
).alias(" DriveLength (meters)"))
|
pass
|
||||||
df.with_columns(
|
try:
|
||||||
(pl.col(" HRCur (bpm)").map_batches(lambda x: savgol_filter(x.to_numpy(), windowsize, 3)).explode()
|
df.with_columns(
|
||||||
).alias(" HRCur (bpm)"))
|
(pl.col(" DriveLength (meters)").map_batches(lambda x: savgol_filter(x.to_numpy(), windowsize, 3)).explode()
|
||||||
df.with_columns((pl.col("forceratio").map_batches(lambda x: savgol_filter(x.to_numpy(), windowsize, 3)).explode()).alias("forceratio"))
|
).alias(" DriveLength (meters)"))
|
||||||
|
except ComputeError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
df.with_columns(
|
||||||
|
(pl.col(" HRCur (bpm)").map_batches(lambda x: savgol_filter(x.to_numpy(), windowsize, 3)).explode()
|
||||||
|
).alias(" HRCur (bpm)"))
|
||||||
|
except ComputeError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
df.with_columns((pl.col("forceratio").map_batches(lambda x: savgol_filter(x.to_numpy(), windowsize, 3)).explode()).alias("forceratio"))
|
||||||
|
except ComputeError:
|
||||||
|
pass
|
||||||
|
|
||||||
df = df.with_columns((pl.col(" DriveLength (meters)") / pl.col(" DriveTime (ms)") * 1.0e3).alias("drivespeed"))
|
df = df.with_columns((pl.col(" DriveLength (meters)") / pl.col(" DriveTime (ms)") * 1.0e3).alias("drivespeed"))
|
||||||
|
|
||||||
@@ -2621,7 +2636,6 @@ def add_c2_stroke_data_db(strokedata, workoutid, starttimeunix, csvfilename,
|
|||||||
' WorkoutState': 4,
|
' WorkoutState': 4,
|
||||||
' ElapsedTime (sec)': seconds,
|
' ElapsedTime (sec)': seconds,
|
||||||
'cum_dist': dist2,
|
'cum_dist': dist2,
|
||||||
' WorkoutState': 0,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
df.sort_values(by='TimeStamp (sec)', ascending=True)
|
df.sort_values(by='TimeStamp (sec)', ascending=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user