class_docstr: Load FeatureSets from files on disk.
  
  This is the base class used to create featureset readers for different
  file types.
  
  Parameters
  ----------
  path_or_list : Union[:class:`skll.types.PathOrStr`, List[Dict[str, Any]]
      Path or a list of example dictionaries.
  
  quiet : bool, default=True
      Do not print "Loading..." status message to stderr.
  
  ids_to_floats : bool, default=False
      Convert IDs to float to save memory. Will raise error
      if we encounter an a non-numeric ID.
  
  label_col : Optional[str], default='y'
      Name of the column which contains the class labels
      for ARFF/CSV/TSV files. If no column with that name
      exists, or ``None`` is specified, the data is
      considered to be unlabelled.
  
  id_col : str, default='id'
      Name of the column which contains the instance IDs.
      If no column with that name exists, or ``None`` is
      specified, example IDs will be automatically generated.
  
  class_map : Optional[:class:`skll.types.ClassMap`], default=None
      Mapping from original class labels to new ones. This is
      mainly used for collapsing multiple labels into a single
      class. Anything not in the mapping will be kept the same.
      The keys are the new labels and the list of values for each
      key is the labels to be collapsed to said new label.
  
  sparse : bool, default=True
      Whether or not to store the features in a numpy CSR
      matrix when using a DictVectorizer to vectorize the
      features.
  
  feature_hasher : bool, default=False
      Whether or not a FeatureHasher should be used to
      vectorize the features.
  
  num_features : Optional[int], default=None
      If using a FeatureHasher, how many features should the
      resulting matrix have?  You should set this to a power
      of 2 greater than the actual number of features to
      avoid collisions.
  
  logger : Optional[logging.Logger], default=None
      A logger instance to use to log messages instead of creating
      a new one by default.
class_docstr_tok: ["Load","FeatureSets","from","files","on","disk",".","This","is","the","base","class","used","to","create","featureset","readers","for","different","file","types",".","Parameters","--","--","--","--","--","path_or_list",":","Union","[",":","class",":","`","skll.types.PathOrStr","`",",","List","[","Dict","[","str",",","Any","]","]","Path","or","a","list","of","example","dictionaries",".","quiet",":","bool",",","default=True","Do","not","print","``","Loading","...","''","status","message","to","stderr",".","ids_to_floats",":","bool",",","default=False","Convert","IDs","to","float","to","save","memory",".","Will","raise","error","if","we","encounter","an","a","non-numeric","ID",".","label_col",":","Optional","[","str","]",",","default=","'","y'","Name","of","the","column","which","contains","the","class","labels","for","ARFF\/CSV\/TSV","files",".","If","no","column","with","that","name","exists",",","or","``","None","``","is","specified",",","the","data","is","considered","to","be","unlabelled",".","id_col",":","str",",","default='id'","Name","of","the","column","which","contains","the","instance","IDs",".","If","no","column","with","that","name","exists",",","or","``","None","``","is","specified",",","example","IDs","will","be","automatically","generated",".","class_map",":","Optional","[",":","class",":","`","skll.types.ClassMap","`","]",",","default=None","Mapping","from","original","class","labels","to","new","ones",".","This","is","mainly","used","for","collapsing","multiple","labels","into","a","single","class",".","Anything","not","in","the","mapping","will","be","kept","the","same",".","The","keys","are","the","new","labels","and","the","list","of","values","for","each","key","is","the","labels","to","be","collapsed","to","said","new","label",".","sparse",":","bool",",","default=True","Whether","or","not","to","store","the","features","in","a","numpy","CSR","matrix","when","using","a","DictVectorizer","to","vectorize","the","features",".","feature_hasher",":","bool",",","default=False","Whether","or","not","a","FeatureHasher","should","be","used","to","vectorize","the","features",".","num_features",":","Optional","[","int","]",",","default=None","If","using","a","FeatureHasher",",","how","many","features","should","the","resulting","matrix","have","?","You","should","set","this","to","a","power","of","2","greater","than","the","actual","number","of","features","to","avoid","collisions",".","logger",":","Optional","[","logging.Logger","]",",","default=None","A","logger","instance","to","use","to","log","messages","instead","of","creating","a","new","one","by","default","."]
docstr: Parse the data frame into ids, labels, and features.
  
  For ``Reader`` objects that rely on ``pandas``, this function
  will be called in the ``_sub_read()`` method to parse the
  data frame into the expected format. It will not be used
  by ``Reader`` classes that read row-by-row (and therefore
  use the ``_sub_read_rows()`` function).
  
  Parameters
  ----------
  df : pandas.DataFrame
      The pandas data frame to parse.
  
  id_col : Optional[str]
      The id column.
  
  label_col : Optional[str]
      The label column.
  
  replace_blanks_with : Optional[Union[Number, Dict[str, Number]]], default=None
      Specifies a new value with which to replace blank values.
      Options are:
  
          - ``Number`` : A (numeric) value with which to replace blank values.
          - ``Dict[str, Number]`` : A dictionary specifying the replacemen
            value for each column.
          - ``None`` : Blank values will be left as blanks, and not replaced.
  
  drop_blanks : bool, default=False
      If ``True``, remove lines/rows that have any blank values.
  
  Returns
  -------
  ids : numpy.ndarray of shape (n_ids,)
      The ids for the feature set.
  
  labels : numpy.ndarray of shape (n_labels,)
      The labels for the feature set.
  
  features : :class:`skll.types.FeatureDictList`
      List of feature dictionaries.
docstr_tok: ["Parse","the","data","frame","into","ids",",","labels",",","and","features",".","For","``","Reader","``","objects","that","rely","on","``","pandas","``",",","this","function","will","be","called","in","the","``","_sub_read","(",")","``","method","to","parse","the","data","frame","into","the","expected","format",".","It","will","not","be","used","by","``","Reader","``","classes","that","read","row-by-row","(","and","therefore","use","the","``","_sub_read_rows","(",")","``","function",")",".","Parameters","--","--","--","--","--","df",":","pandas.DataFrame","The","pandas","data","frame","to","parse",".","id_col",":","Optional","[","str","]","The","id","column",".","label_col",":","Optional","[","str","]","The","label","column",".","replace_blanks_with",":","Optional","[","Union","[","Number",",","Dict","[","str",",","Number","]","]","]",",","default=None","Specifies","a","new","value","with","which","to","replace","blank","values",".","Options","are",":","-","``","Number","``",":","A","(","numeric",")","value","with","which","to","replace","blank","values",".","-","``","Dict","[","str",",","Number","]","``",":","A","dictionary","specifying","the","replacemen","value","for","each","column",".","-","``","None","``",":","Blank","values","will","be","left","as","blanks",",","and","not","replaced",".","drop_blanks",":","bool",",","default=False","If","``","True","``",",","remove","lines\/rows","that","have","any","blank","values",".","Returns","--","--","--","-","ids",":","numpy.ndarray","of","shape","(","n_ids",",",")","The","ids","for","the","feature","set",".","labels",":","numpy.ndarray","of","shape","(","n_labels",",",")","The","labels","for","the","feature","set",".","features",":",":","class",":","`","skll.types.FeatureDictList","`","List","of","feature","dictionaries","."]
code: def _parse_dataframe(
      self,
      df: pd.DataFrame,
      id_col: Optional[str],
      label_col: Optional[str],
      replace_blanks_with: Optional[
          Union[Number, Dict[str, Number]]
      ] = None,
      drop_blanks: bool = False,
  ) -> Tuple[np.ndarray, np.ndarray, FeatureDictList]:
      """
      Parse the data frame into ids, labels, and features.
  
      For ``Reader`` objects that rely on ``pandas``, this function
      will be called in the ``_sub_read()`` method to parse the
      data frame into the expected format. It will not be used
      by ``Reader`` classes that read row-by-row (and therefore
      use the ``_sub_read_rows()`` function).
  
      Parameters
      ----------
      df : pandas.DataFrame
          The pandas data frame to parse.
  
      id_col : Optional[str]
          The id column.
  
      label_col : Optional[str]
          The label column.
  
      replace_blanks_with : Optional[Union[Number, Dict[str, Number]]], default=None
          Specifies a new value with which to replace blank values.
          Options are:
  
              - ``Number`` : A (numeric) value with which to replace blank values.
              - ``Dict[str, Number]`` : A dictionary specifying the replacemen
                value for each column.
              - ``None`` : Blank values will be left as blanks, and not replaced.
  
      drop_blanks : bool, default=False
          If ``True``, remove lines/rows that have any blank values.
  
      Returns
      -------
      ids : numpy.ndarray of shape (n_ids,)
          The ids for the feature set.
  
      labels : numpy.ndarray of shape (n_labels,)
          The labels for the feature set.
  
      features : :class:`skll.types.FeatureDictList`
          List of feature dictionaries.
      """
      if df.empty:
          raise ValueError(
              "No features found in possibly empty file "
              f"'{self.path_or_list}'."
          )
  
      if drop_blanks and replace_blanks_with is not None:
          raise ValueError(
              "You cannot both drop blanks and replace them. "
              "'replace_blanks_with' can only have a value when "
              "'drop_blanks' is `False`."
          )
  
      # should we replace blank values with something?
      if replace_blanks_with is not None:
          self.logger.info(
              "Blank values in all rows/lines will be replaced with "
              "user-specified value(s)."
          )
          df = df.fillna(replace_blanks_with)
  
      # should we remove lines that have any NaNs?
      if drop_blanks:
          self.logger.info(
              "Rows/lines with any blank values will be dropped."
          )
          df = df.dropna().reset_index(drop=True)
  
          # if the dataframe has no rows left after removing blanks,
          # raise an exception here because downstream processing
          # will run into issues
          if df.empty:
              raise ValueError(
                  "No rows/lines left in the feature file "
                  "after dropping blank values."
              )
  
      # if the id column exists,
      # get them from the data frame and
      # delete the column; otherwise, just
      # set it to None
      if id_col is not None and id_col in df:
          ids = df[id_col].astype(str)
          del df[id_col]
          # if `ids_to_floats` is True,
          # then convert the ids to floats
          if self.ids_to_floats:
              ids = ids.astype(float)
          ids = ids.values
      else:
          # create ids with the prefix `EXAMPLE_`
          ids = np.array([f"EXAMPLE_{i}" for i in range(df.shape[0])])
  
      # if the label column exists,
      # get them from the data frame and
      # delete the column; otherwise, just
      # set it to None
      if label_col is not None and label_col in df:
          labels = df[label_col]
          del df[label_col]
          # if `class_map` exists, then
          # map the new classes to the labels;
          # otherwise, just convert them to floats
          if self.class_map is not None:
              labels = labels.apply(
                  safe_float, replace_dict=self.class_map
              )
          else:
              labels = labels.apply(safe_float)
          labels = labels.values
      else:
          # create an array of Nones
          labels = np.array([None] * df.shape[0])
  
      # convert the remaining features to
      # a list of dictionaries
      features = df.to_dict(orient="records")
  
      return ids, labels, features
  
imports: import csv
  import json
  import logging
  import re
  import sys
  from io import StringIO
  from itertools import chain
  from numbers import Number
  from pathlib import Path
  from typing import IO, Any, Dict, List, Optional, Tuple, Union
  import numpy
  import pandas
  from bs4 import UnicodeDammit
  from sklearn.feature_extraction import FeatureHasher
  from skll.data import FeatureSet
  from skll.data.dict_vectorizer import DictVectorizer
  from skll.types import ClassMap, FeatGenerator, FeatureDictList, IdType, LabelType, PathOrStr
label_desc: Use image node_id 6 for calling the Reader obj's underlying member method code with example usage: obj._parse_dataframe(df, id_col, label_col, replace_blanks_with, drop_blanks) and returns: ids,  labels,  features