code: def EDA_find_remove_columns_with_infinity(
      df, remove=False, verbose=0
  ):
      """
      This function finds all columns in a dataframe that have inifinite values (np.inf or -np.inf)
      It returns a list of column names. If the list is empty, it means no columns were found.
      If remove flag is set, then it returns a smaller dataframe with inf columns removed.
      """
      nums = df.select_dtypes(include="number").columns.tolist()
      dfx = df[nums]
      sum_rows = np.isinf(dfx).values.sum()
      add_cols = list(dfx.columns.to_series()[np.isinf(dfx).any()])
      if sum_rows > 0:
          if verbose > 0:
              print(
                  "    there are %d rows and %d columns with infinity in them..."
                  % (sum_rows, len(add_cols))
              )
          if remove:
              ### here you need to use df since the whole dataset is involved ###
              nocols = [x for x in df.columns if x not in add_cols]
              if verbose > 0:
                  print(
                      "    Shape of dataset before %s and after %s removing columns with infinity"
                      % (df.shape, (df[nocols].shape,))
                  )
              return df[nocols]
          else:
              ## this will be a list of columns with infinity ####
              return add_cols
      else:
          ## this will be an empty list if there are no columns with infinity
          return add_cols
  
file_path: AutoViz/autoviz/classify_method.py
imports: import numpy
  import pandas
  import random
  import warnings
  from sklearn.exceptions import DataConversionWarning
  import logging
  from functools import reduce
  import copy
  import time
  import copy
label_desc: Use image node_id 3 for calling a global function with example usage: EDA_find_remove_columns_with_infinity(df, remove, verbose) and returns: add_cols, df, add_cols