class_docstr: Writer for writing out ``FeatureSet`` instances as CSV files.
  
  Parameters
  ----------
  path : :class:`skll.types.PathOrStr`
      A path to the feature file we would like to create.
      If ``subsets`` is not ``None``, this is assumed to be a string
      containing the path to the directory to write the feature
      files with an additional file extension specifying the file
      type. For example ``/foo/.csv``.
  
  feature_set : :class:`skll.data.featureset.FeatureSet`
      The ``FeatureSet`` instance to dump to the output file.
  
  quiet : bool, default=True
      Do not print "Writing..." status message to stderr.
  
  subsets : Optional[Dict[str, List[str]]], default=None
      A mapping from subset names to lists of feature names
      that are included in those sets. If given, a feature
      file will be written for every subset (with the name
      containing the subset name as suffix to ``path``).
      Note, since string- valued features are automatically
      converted into boolean features with names of the form
      ``FEATURE_NAME=STRING_VALUE``, when doing the
      filtering, the portion before the ``=`` is all that's
      used for matching. Therefore, you do not need to
      enumerate all of these boolean feature names in your
      mapping.
  
  logger : Optional[logging.Logger], default=None
      A logger instance to use to log messages instead of creating
      a new one by default.
  
  label_col : str, default="y"
      The column name containing the label.
  
  id_col : str, default="id"
      The column name containing the ID.
  
  pandas_kwargs : Optional[Dict[str], Any], default=None
      Arguments that will be passed directly to the `pandas` I/O reader.
class_docstr_tok: ["Writer","for","writing","out","``","FeatureSet","``","instances","as","CSV","files",".","Parameters","--","--","--","--","--","path",":",":","class",":","`","skll.types.PathOrStr","`","A","path","to","the","feature","file","we","would","like","to","create",".","If","``","subsets","``","is","not","``","None","``",",","this","is","assumed","to","be","a","string","containing","the","path","to","the","directory","to","write","the","feature","files","with","an","additional","file","extension","specifying","the","file","type",".","For","example","``","\/foo\/.csv","``",".","feature_set",":",":","class",":","`","skll.data.featureset.FeatureSet","`","The","``","FeatureSet","``","instance","to","dump","to","the","output","file",".","quiet",":","bool",",","default=True","Do","not","print","``","Writing","...","''","status","message","to","stderr",".","subsets",":","Optional","[","Dict","[","str",",","List","[","str","]","]","]",",","default=None","A","mapping","from","subset","names","to","lists","of","feature","names","that","are","included","in","those","sets",".","If","given",",","a","feature","file","will","be","written","for","every","subset","(","with","the","name","containing","the","subset","name","as","suffix","to","``","path","``",")",".","Note",",","since","string-","valued","features","are","automatically","converted","into","boolean","features","with","names","of","the","form","``","FEATURE_NAME=STRING_VALUE","``",",","when","doing","the","filtering",",","the","portion","before","the","``","=","``","is","all","that's","used","for","matching",".","Therefore",",","you","do","not","need","to","enumerate","all","of","these","boolean","feature","names","in","your","mapping",".","logger",":","Optional","[","logging.Logger","]",",","default=None","A","logger","instance","to","use","to","log","messages","instead","of","creating","a","new","one","by","default",".","label_col",":","str",",","default=","''","y","''","The","column","name","containing","the","label",".","id_col",":","str",",","default=","''","id","''","The","column","name","containing","the","ID",".","pandas_kwargs",":","Optional","[","Dict","[","str","]",",","Any","]",",","default=None","Arguments","that","will","be","passed","directly","to","the","`","pandas","`","I\/O","reader","."]
docstr: Create and filter data frame with features in given feature set.
  
  Add the IDs and labels, if applicable. If the data frame
  with features already exists, pass `df_features`. Then the IDs and labels will
  simply be added to the existing data frame containing the features.
  
  Parameters
  ----------
  feature_set : :class:`skll.data.featureset.FeatureSet`
      The ``FeatureSet`` instance being written to a file.
  
  filter_features : Optional[Set[str]], default=None
      If only writing a subset of the features in the
      FeatureSet to ``output_file``, these are the
      features to include in this file.
  
  df_features : Optional[pandas.DataFrame], default=None
      If the data frame with features already exists,
      then we use it and add IDs and labels; otherwise,
      the feature data frame will be created from the feature set.
  
  Returns
  -------
  df_features : pandas.DataFrame
      The data frame constructed from the feature set.
  
  Raises
  ------
  ValueError
      If ID column is already used as feature.
      If label column is already used as feature.
docstr_tok: ["Create","and","filter","data","frame","with","features","in","given","feature","set",".","Add","the","IDs","and","labels",",","if","applicable",".","If","the","data","frame","with","features","already","exists",",","pass","`","df_features","`",".","Then","the","IDs","and","labels","will","simply","be","added","to","the","existing","data","frame","containing","the","features",".","Parameters","--","--","--","--","--","feature_set",":",":","class",":","`","skll.data.featureset.FeatureSet","`","The","``","FeatureSet","``","instance","being","written","to","a","file",".","filter_features",":","Optional","[","Set","[","str","]","]",",","default=None","If","only","writing","a","subset","of","the","features","in","the","FeatureSet","to","``","output_file","``",",","these","are","the","features","to","include","in","this","file",".","df_features",":","Optional","[","pandas.DataFrame","]",",","default=None","If","the","data","frame","with","features","already","exists",",","then","we","use","it","and","add","IDs","and","labels",";","otherwise",",","the","feature","data","frame","will","be","created","from","the","feature","set",".","Returns","--","--","--","-","df_features",":","pandas.DataFrame","The","data","frame","constructed","from","the","feature","set",".","Raises","--","--","--","ValueError","If","ID","column","is","already","used","as","feature",".","If","label","column","is","already","used","as","feature","."]
code: def _build_dataframe(
      self,
      feature_set: FeatureSet,
      filter_features: Optional[Set[str]] = None,
      df_features: Optional[pd.DataFrame] = None,
  ) -> pd.DataFrame:
      """
      Create and filter data frame with features in given feature set.
  
      Add the IDs and labels, if applicable. If the data frame
      with features already exists, pass `df_features`. Then the IDs and labels will
      simply be added to the existing data frame containing the features.
  
      Parameters
      ----------
      feature_set : :class:`skll.data.featureset.FeatureSet`
          The ``FeatureSet`` instance being written to a file.
  
      filter_features : Optional[Set[str]], default=None
          If only writing a subset of the features in the
          FeatureSet to ``output_file``, these are the
          features to include in this file.
  
      df_features : Optional[pandas.DataFrame], default=None
          If the data frame with features already exists,
          then we use it and add IDs and labels; otherwise,
          the feature data frame will be created from the feature set.
  
      Returns
      -------
      df_features : pandas.DataFrame
          The data frame constructed from the feature set.
  
      Raises
      ------
      ValueError
          If ID column is already used as feature.
          If label column is already used as feature.
      """
      # create the data frame with just the features
      # from the feature set, at this point
      if df_features is None:
          df_features = self._build_dataframe_with_features(
              feature_set, filter_features
          )
  
      # if the id column is already in the data frame,
      # then raise an error; otherwise, just add the ids
      if self.id_col in df_features:
          raise ValueError(
              f"ID column name {self.id_col} already used as feature name."
          )
      df_features[self.id_col] = feature_set.ids
  
      # if the the labels should exist but the column is already
      # in the data frame, then raise an error; otherwise, just add the labels
      if feature_set.has_labels:
          if self.label_col in df_features:
              raise ValueError(
                  f'Class column name "{self.label_col}" '
                  "already used as feature name."
              )
          df_features[self.label_col] = feature_set.labels
  
      return df_features
  
imports: import json
  import logging
  import sys
  from csv import DictWriter
  from decimal import Decimal
  from pathlib import Path
  from typing import IO, Any, Dict, List, Optional, Set, Tuple, Union
  import numpy
  import pandas
  from scipy.sparse import issparse
  from sklearn.feature_extraction import DictVectorizer, FeatureHasher
  from skll.data import FeatureSet
  from skll.types import FeatGenerator, FeatureDict, IdType, LabelType, PathOrStr
label_desc: Use image node_id 3 for calling the CSVWriter obj's underlying member method code with example usage: obj._build_dataframe(feature_set, filter_features, df_features) and returns: df_features