Creating new column in dataframe based on conditions in 2 other columns
-the problem with an inaccurate filling of column group_gender is that in df['group_gender'] = 'dp_m' in the following code, if i == 'M' you are filling the whole column with dp_m, instead you should use methods like iloc but it is not really an efficient way specifically when having a large dataset. In following, I have provided a better way.

for i in df['gender']:
    if i == 'M':
        df['group_gender'] = 'dp_m'
            else: 
        df['group_gender'] = 'dp_f'


The more appropriate way

#creating an instant dataframe
import pandas as pd
d = {'gender':['M','M','F', 'M', 'F','M']}
df = pd.DataFrame(d)

#filling the 'group_gender' column
df.loc[df['gender'] == 'M', 'group_gender'] = 'dp_m'
df.loc[df['gender'] == 'F', 'group_gender'] = 'dp_f'


-You are not filling in experimental_gropuping and returning the column:

group(df['experimental_grouping'])


-What is this group? (Can you provide more details about the first part of your code?)