0

The code:

def clean(df):
    df = df.rename(columns={'Pigm. 2 Name': 'pigm_2_name', 'Pigm. 2 [%]': 'pigm_2_g',})
   
    binder_cols = ['bm_1_name', 'bm_2_name', 'bm_2_name']
    binder_map = {'At': 'AT',
                  'EP ': 'EP'}
    df = unify_categories(df, binder_cols, binder_map)
    pigm_cols = ['pigm_1_name', 'pigm_2_name', 'pigm_3_name', 'pigm_4_name', 'pigm_5_name']
    pigm_map = {'blue2R': 'blue 2R'}

    df = unify_categories(df, pigm_cols, pigm_map)
    str_replace = {
                   'blau 40 ': 'blau 40',
                   'blau 451 ': 'blau 451',
                   'blue 477': 'blau 477',
                   }
    ->Now the part that doesnt function
    if(df != dataset2):
      df = rearrange_binders(df)

    return df

dataset1 = clean(dataset1)
dataset2 = clean(dataset2)

As seen in the above code, I want to clean the datasets in the def clean function. This works fine as intended. However, at the end of the function, I want to execute the following line of code only for datasets other than the second one: df = rearrange_binders(df) Unfortunately, this has not worked for me yet. I also cannot find anything in the df documentation on how to compare 2 Dataframes.

Any help would be greatly appreciated. Thank you.

I want to compare a Dateframe so only specific Dataframes get into a if clause.

  • `df` is changed by the operations in `clean` and therefore never equal to `dataset2` at the end. At beginning of `clean` you can add e.g. `is_ds2 = df == dataset2` and replace the if-condition by `not is_ds2`. – Michael Butscher Apr 11 '23 at 08:50

0 Answers0