Pandas: Groupby, Apply And Repeat

IIUC, just join them afterwards:

df_test.join(WMs, on=df_test.Class, rsuffix="_WMean")

Output:

  Class  X  Y  Z  W  X_WMean  Y_WMean  Z_WMean
0     A  0  0  0  1      1.0      1.0      1.0
1     A  1  1  1  1      1.0      1.0      1.0
2     A  2  2  2  1      1.0      1.0      1.0
3     B  3  3  3  2      4.0      4.0      4.0
4     B  4  4  4  2      4.0      4.0      4.0
5     B  5  5  5  2      4.0      4.0      4.0