Want to get involved? We're always looking for ideas and content for Weekly Challenges.
SUBMIT YOUR IDEAIt takes longer to understand the question than to build the workflow.
Bit Complex to understand the Problem Statement with a weird output.
Hi All,
I did not understand the use of Dynamic rename toll in the workflow. Could you please help me out?
My output looks different. I put it back in a 2-dimensional table. I had 8,208 rows (1,368 original rows x 6 columns) when I transposed the data (solution has 25k)
Workflow
Tabular data
Finally figured out a way to clean up the python code for this one:
from ayx import Alteryx
df = Alteryx.read('#1')
# first part of [] is the row selection, so we are selecting all rows
# followed by the fields 3-8 (zero indexed)
# for each field in that selection, run 3Mo
# (and prefix the new field with "3Mo_")
# then run 6Mo average and prefix with "6Mo_"
for i in df.iloc[:,3:8]:
df['3Mo_'+i] = df.groupby('RM Category')[i].transform(lambda x: x.rolling(3,1).mean())
df['6Mo_'+i] = df.groupby('RM Category')[i].transform(lambda x: x.rolling(6,1).mean())
Alteryx.write(df,1)
# The longer form of the above code is:
df['3Mo_C.LK98'] = df.groupby('RM Category')['C.LK98'].transform(lambda x: x.rolling(3,1).mean())
df['3Mo_P.LK98'] = df.groupby('RM Category')['P.LK98'].transform(lambda x: x.rolling(3,1).mean())
df['3Mo_C.1K'] = df.groupby('RM Category')['C.1K'].transform(lambda x: x.rolling(3,1).mean())
df['3Mo_D.1K'] = df.groupby('RM Category')['D.1K'].transform(lambda x: x.rolling(3,1).mean())
df['3Mo_C.NLP3'] = df.groupby('RM Category')['C.NLP3'].transform(lambda x: x.rolling(3,1).mean())
df['3Mo_P.NLP3'] = df.groupby('RM Category')['P.NLP3'].transform(lambda x: x.rolling(3,1).mean())
df['6Mo_C.LK98'] = df.groupby('RM Category')['C.LK98'].transform(lambda x: x.rolling(6,1).mean())
df['6Mo_P.LK98'] = df.groupby('RM Category')['P.LK98'].transform(lambda x: x.rolling(6,1).mean())
df['6Mo_C.1K'] = df.groupby('RM Category')['C.1K'].transform(lambda x: x.rolling(6,1).mean())
df['6Mo_D.1K'] = df.groupby('RM Category')['D.1K'].transform(lambda x: x.rolling(6,1).mean())
df['6Mo_C.NLP3'] = df.groupby('RM Category')['C.NLP3'].transform(lambda x: x.rolling(6,1).mean())
df['6Mo_P.NLP3'] = df.groupby('RM Category')['P.NLP3'].transform(lambda x: x.rolling(6,1).mean())
Alteryx.write(df,2)
#SnakingMyWayThruChallenges
100% did not understand this challenge and looking at the solution didn't clear up the goal, but hey this is what I came up with.