title: Apply user defined function on whole dataframe in Pandas
body: <p>I have to perform the same data cleaning for multiple CSV files. I wrote a function to do it but I'm not getting any solution. I understand to use a user-defined function we must use the apply() function but those are for rows and columns and I want to do it for the whole dataframe.
  My function code is below:</p>
  <pre><code>def transform_data(df):
     # split into multiple columns
     df = pd.concat([df['Unnamed: 0'], df['NFHS-5'].str.split(' ', expand=True),
                  df['Unnamed: 2'], df['NFHS-4']], axis=1)
     # rename columns
     df = df.rename(columns={0: 'AP_NFHS_5_Urban', 2: 'AP_NFHS_5_Rural', 4: 'AP_NFHS_5_Total',
                          'Unnamed: 0': 'State_NFHS', 'NFHS-4': 'AP_NFHS_4'})
     # join 2 columns
     df['AP_NFHS_5_Total'] = df['AP_NFHS_5_Total'].fillna(df['Unnamed: 2'])
     # remove null columns
     df = df.dropna(subset=['AP_NFHS_5_Total'])
     df = df.dropna(subset=['AP_NFHS_5_Rural'])
     return df
  </code></pre>
  <p>How should I call it? Can I even do it?
  Any help will be appreciated. Thanks.</p>