I have a dataset with multiple variables. I am trying to group these variables according to the end of the name of variable and calculate the mean of each group. Here is an example of my dataset:
data = {'AST_0-01': [1, 2, 3],
'AST_0-02': [4, 5, 6],
'AST_1-01': [7, 8, 9],
'AST_1-02': [1, 2, 3],
'AST_2-01': [4, 5, 6],
'AST_2-02': [7, 8, 9]}
df = pd.DataFrame(data)
What I am trying to do is to group the variables that ends with the same number, e.g.: [AST_0-01, AST_1-01, AST_2-01], [AST_0-02, AST_1-02, AST_2-02], and then get the means.