class_docstr: Convert a pandas DataFrame to a suitable VW format.
  Instances of this class are built with classes such as SimpleLabel,
  MulticlassLabel, Feature or Namespace.
  
  The class also provided a convenience constructor to initialize the class
  based on the target/features column names only.
class_docstr_tok: ["Convert","a","pandas","DataFrame","to","a","suitable","VW","format",".","Instances","of","this","class","are","built","with","classes","such","as","SimpleLabel",",","MulticlassLabel",",","Feature","or","Namespace",".","The","class","also","provided","a","convenience","constructor","to","initialize","the","class","based","on","the","target\/features","column","names","only","."]
docstr: Initialize a DFtoVW instance.
  
  Args:
      df: The dataframe to convert to VW input format.
      features: One or more Feature object(s).
      namespaces: One or more Namespace object(s), each of being composed of one or
          more Feature object(s).
      label: One or more label objects used to build the label string
      tag: The tag column name (used as identifiers for examples).
  
  Examples:
      >>> from vowpalwabbit.dftovw import DFtoVW, SimpleLabel, Feature, Namespace
      >>> import pandas as pd
  
      >>> df = pd.DataFrame({"y": [1], "a": [2], "b": [3], "c": [4]})
      >>> conv1 = DFtoVW(df=df,
      ...                label=SimpleLabel("y"),
      ...                features=Feature("a"))
      >>> conv1.convert_df()
      ['1 | a:2']
  
      >>> conv2 = DFtoVW(df=df,
      ...                label=SimpleLabel("y"),
      ...                features=[Feature(col) for col in ["a", "b"]])
      >>> conv2.convert_df()
      ['1 | a:2 b:3']
  
      >>> conv3 = DFtoVW(df=df,
      ...                label=SimpleLabel("y"),
      ...                namespaces=Namespace(
      ...                        name="DoubleIt", value=2,
      ...                        features=Feature(value="a", rename_feature="feat_a")))
      >>> conv3.convert_df()
      ['1 |DoubleIt:2 feat_a:2']
  
      >>> conv4 = DFtoVW(df=df,
      ...                label=SimpleLabel("y"),
      ...                namespaces=[Namespace(name="NS1", features=[Feature(col) for col in ["a", "c"]]),
      ...                            Namespace(name="NS2", features=Feature("b"))])
      >>> conv4.convert_df()
      ['1 |NS1 a:2 c:4 |NS2 b:3']
docstr_tok: ["Initialize","a","DFtoVW","instance",".","Args",":","df",":","The","dataframe","to","convert","to","VW","input","format",".","features",":","One","or","more","Feature","object","(","s",")",".","namespaces",":","One","or","more","Namespace","object","(","s",")",",","each","of","being","composed","of","one","or","more","Feature","object","(","s",")",".","label",":","One","or","more","label","objects","used","to","build","the","label","string","tag",":","The","tag","column","name","(","used","as","identifiers","for","examples",")",".","Examples",":",">",">",">","from","vowpalwabbit.dftovw","import","DFtoVW",",","SimpleLabel",",","Feature",",","Namespace",">",">",">","import","pandas","as","pd",">",">",">","df","=","pd.DataFrame","(","{","``","y","''",":","[","1","]",",","``","a","''",":","[","2","]",",","``","b","''",":","[","3","]",",","``","c","''",":","[","4","]","}",")",">",">",">","conv1","=","DFtoVW","(","df=df",",","...","label=SimpleLabel","(","``","y","''",")",",","...","features=Feature","(","``","a","''",")",")",">",">",">","conv1.convert_df","(",")","[","'","1","|","a:2","'","]",">",">",">","conv2","=","DFtoVW","(","df=df",",","...","label=SimpleLabel","(","``","y","''",")",",","...","features=","[","Feature","(","col",")","for","col","in","[","``","a","''",",","``","b","''","]","]",")",">",">",">","conv2.convert_df","(",")","[","'","1","|","a:2","b:3","'","]",">",">",">","conv3","=","DFtoVW","(","df=df",",","...","label=SimpleLabel","(","``","y","''",")",",","...","namespaces=Namespace","(","...","name=","''","DoubleIt","''",",","value=2",",","...","features=Feature","(","value=","''","a","''",",","rename_feature=","''","feat_a","''",")",")",")",">",">",">","conv3.convert_df","(",")","[","'","1","|DoubleIt:2","feat_a:2","'","]",">",">",">","conv4","=","DFtoVW","(","df=df",",","...","label=SimpleLabel","(","``","y","''",")",",","...","namespaces=","[","Namespace","(","name=","''","NS1","''",",","features=","[","Feature","(","col",")","for","col","in","[","``","a","''",",","``","c","''","]","]",")",",","...","Namespace","(","name=","''","NS2","''",",","features=Feature","(","``","b","''",")",")","]",")",">",">",">","conv4.convert_df","(",")","[","'","1","|NS1","a:2","c:4","|NS2","b:3","'","]"]
code: def __init__(
      self,
      df: pd.DataFrame,
      features: Optional[Union[Feature, List[Feature]]] = None,
      namespaces: Optional[Union[Namespace, List[Namespace]]] = None,
      label: Optional[
          Union[
              SimpleLabel,
              MulticlassLabel,
              MultiLabel,
              ContextualbanditLabel,
              List[MultiLabel],
              List[ContextualbanditLabel],
          ]
      ] = None,
      tag: Optional[Hashable] = None,
  ):
      """Initialize a DFtoVW instance.
  
      Args:
          df: The dataframe to convert to VW input format.
          features: One or more Feature object(s).
          namespaces: One or more Namespace object(s), each of being composed of one or
              more Feature object(s).
          label: One or more label objects used to build the label string
          tag: The tag column name (used as identifiers for examples).
  
      Examples:
          >>> from vowpalwabbit.dftovw import DFtoVW, SimpleLabel, Feature, Namespace
          >>> import pandas as pd
  
          >>> df = pd.DataFrame({"y": [1], "a": [2], "b": [3], "c": [4]})
          >>> conv1 = DFtoVW(df=df,
          ...                label=SimpleLabel("y"),
          ...                features=Feature("a"))
          >>> conv1.convert_df()
          ['1 | a:2']
  
          >>> conv2 = DFtoVW(df=df,
          ...                label=SimpleLabel("y"),
          ...                features=[Feature(col) for col in ["a", "b"]])
          >>> conv2.convert_df()
          ['1 | a:2 b:3']
  
          >>> conv3 = DFtoVW(df=df,
          ...                label=SimpleLabel("y"),
          ...                namespaces=Namespace(
          ...                        name="DoubleIt", value=2,
          ...                        features=Feature(value="a", rename_feature="feat_a")))
          >>> conv3.convert_df()
          ['1 |DoubleIt:2 feat_a:2']
  
          >>> conv4 = DFtoVW(df=df,
          ...                label=SimpleLabel("y"),
          ...                namespaces=[Namespace(name="NS1", features=[Feature(col) for col in ["a", "c"]]),
          ...                            Namespace(name="NS2", features=Feature("b"))])
          >>> conv4.convert_df()
          ['1 |NS1 a:2 c:4 |NS2 b:3']
      """
      self.df = df
      self.n_rows = df.shape[0]
      if isinstance(label, list):
          self.label = _ListLabel(label)
      else:
          self.label = label
      self.tag = _Tag(tag) if tag else None
  
      if label is not None:
          self.check_label_type()
  
      if features is not None:
          self.check_features_type(features)
  
      self.set_namespaces(namespaces, features)
      self.check_namespaces_type()
  
      self.check_missing_columns_df()
      self.check_columns_type_and_values()
  
imports: import warnings
  import numpy
  import pandas
  from typing import Any, Hashable, List, Optional, Tuple, Type, Union
label_desc: Use image node_id 1 to create a new DFtoVW object  with example: obj = DFtoVW(df, features, namespaces, label, tag)