add read_cols_pl
This commit is contained in:
@@ -1659,6 +1659,44 @@ def prepmultipledata(ids, verbose=False): # pragma: no cover
|
|||||||
# Read a set of columns for a set of workout ids, returns data as a
|
# Read a set of columns for a set of workout ids, returns data as a
|
||||||
# pandas dataframe
|
# pandas dataframe
|
||||||
|
|
||||||
|
def read_cols_pl(ids, columns):
|
||||||
|
extracols = []
|
||||||
|
|
||||||
|
|
||||||
|
columns = list(columns) + ['distance', 'spm', 'workoutid']
|
||||||
|
columns = [x for x in columns if x != 'None']
|
||||||
|
columns = list(set(columns))
|
||||||
|
ids = [int(id) for id in ids]
|
||||||
|
|
||||||
|
df = pl.DataFrame()
|
||||||
|
|
||||||
|
if len(ids) == 0:
|
||||||
|
return pl.DataFrame()
|
||||||
|
|
||||||
|
df = getsmallrowdata_pl(columns, ids=ids, doclean=False, compute=False)
|
||||||
|
|
||||||
|
if 'peakforce' in columns:
|
||||||
|
funits = ((w.id, w.forceunit)
|
||||||
|
for w in Workout.objects.filter(id__in=ids))
|
||||||
|
for id, u in funits:
|
||||||
|
if u == 'lbs':
|
||||||
|
df = df.with_columns(
|
||||||
|
peakforce=pl.when(pl.col('workoutid')==id)
|
||||||
|
.then(pl.col('peakforce') * lbstoN)
|
||||||
|
.otherwise(pl.col('peakforce')))
|
||||||
|
if 'averageforce' in columns:
|
||||||
|
funits = ((w.id, w.forceunit)
|
||||||
|
for w in Workout.objects.filter(id__in=ids))
|
||||||
|
for id, u in funits:
|
||||||
|
if u == 'lbs':
|
||||||
|
df = df.with_columns(
|
||||||
|
averageforce=pl.when(pl.col('workoutid')==id)
|
||||||
|
.then(pl.col('averageforce') * lbstoN)
|
||||||
|
.otherwise(pl.col('averageforce')))
|
||||||
|
|
||||||
|
|
||||||
|
return df, extracols
|
||||||
|
|
||||||
|
|
||||||
def read_cols_df_sql(ids, columns, convertnewtons=True):
|
def read_cols_df_sql(ids, columns, convertnewtons=True):
|
||||||
# drop columns that are not in offical list
|
# drop columns that are not in offical list
|
||||||
|
|||||||
Reference in New Issue
Block a user