Transposing part of a pandas dataframe,df = df[~((df['group_A'] == 0) | (df['group_B'] == 0))]