code: def df_to_simple_rdd(
      df,
      categorical=False,
      nb_classes=None,
      features_col="features",
      label_col="label",
  ):
      """Convert DataFrame into RDD of pairs"""
      sql_context = df.sql_ctx
      sql_context.registerDataFrameAsTable(df, "temp_table")
      selected_df = sql_context.sql(
          "SELECT {0} AS features, {1} as label from temp_table".format(
              features_col, label_col
          )
      )
      if isinstance(selected_df.first().features, MLLibVector):
          lp_rdd = selected_df.rdd.map(
              lambda row: LabeledPoint(row.label, row.features)
          )
      else:
          lp_rdd = selected_df.rdd.map(
              lambda row: LabeledPoint(
                  row.label, MLLibVectors.fromML(row.features)
              )
          )
      rdd = lp_to_simple_rdd(lp_rdd, categorical, nb_classes)
      return rdd
  
imports: from pyspark.sql import SQLContext
  from pyspark.mllib.regression import LabeledPoint
  from ..utils.rdd_utils import from_labeled_point, to_labeled_point, lp_to_simple_rdd
  from pyspark.mllib.linalg import Vector, Vectors
label_desc: Use image node_id 3 for calling a global function with example usage: df_to_simple_rdd(df, categorical, nb_classes, features_col, label_col) and returns: rdd