I am using this code to get the difference between the row values for all column combinations (tups).
new_df = df[['seg_wd','ter_wd','qua_wd','qui_wd','sex_wd']]
def all_subsets(ss):
return chain(*map(lambda x: combinations(ss, x), range(1, len(ss)+1)))
--get all combination
tups = list(all_subsets(new_df.columns))
tups = tups[5:15]
--for each combination multiple values
df1 = pd.concat([new_df.loc[:,c].diff(axis=1) for c in tups], axis=1)
However, I am getting 20 columns on the output dataframe instead of 10. Since I have repeated column names, I am unable to select the columns I want by their name. How can I select columns using their index? (Note: In this case, I want columns [1,3,5,7,9,11,13,15,17,19])
Or does anyone know a more efficient way to get the output I need?
Thanks a lot :)