class_docstr: Reads and cleans data
  
  Parameters
  ----------
  sep : str, defaut = None
       Delimiter to use when reading a csv file.
  
  header : int or None, default = 0.
      If header=0, the first line is considered as a header.
      Otherwise, there is no header.
      Useful for csv and xls files.
  
  to_hdf5 : bool, default = True
      If True, dumps each file to hdf5 format.
  
  to_path : str, default = "save"
      Name of the folder where files and encoders are saved.
  
  verbose : bool, defaut = True
      Verbose mode
class_docstr_tok: ["Reads","and","cleans","data","Parameters","--","--","--","--","--","sep",":","str",",","defaut","=","None","Delimiter","to","use","when","reading","a","csv","file",".","header",":","int","or","None",",","default","=","0",".","If","header=0",",","the","first","line","is","considered","as","a","header",".","Otherwise",",","there","is","no","header",".","Useful","for","csv","and","xls","files",".","to_hdf5",":","bool",",","default","=","True","If","True",",","dumps","each","file","to","hdf5","format",".","to_path",":","str",",","default","=","``","save","''","Name","of","the","folder","where","files","and","encoders","are","saved",".","verbose",":","bool",",","defaut","=","True","Verbose","mode"]
docstr: Reads and cleans data (accepted formats : csv, xls, json and h5):
  
  - del Unnamed columns
  - casts lists into variables
  - try to cast variables into float
  - cleans dates and extracts timestamp from 01/01/2017, year, month, day, day_of_week and hour
  - drop duplicates (if drop_duplicate=True)
  
  Parameters
  ----------
  path : str
      The path to the dataset.
  
  drop_duplicate: bool, default = False
      If True, drop duplicates when reading each file.
  
  Returns
  -------
  pandas dataframe
      Cleaned dataset.
docstr_tok: ["Reads","and","cleans","data","(","accepted","formats",":","csv",",","xls",",","json","and","h5",")",":","-","del","Unnamed","columns","-","casts","lists","into","variables","-","try","to","cast","variables","into","float","-","cleans","dates","and","extracts","timestamp","from","01\/01\/2017",",","year",",","month",",","day",",","day_of_week","and","hour","-","drop","duplicates","(","if","drop_duplicate=True",")","Parameters","--","--","--","--","--","path",":","str","The","path","to","the","dataset",".","drop_duplicate",":","bool",",","default","=","False","If","True",",","drop","duplicates","when","reading","each","file",".","Returns","--","--","--","-","pandas","dataframe","Cleaned","dataset","."]
code: def clean(self, path, drop_duplicate=False):
      """Reads and cleans data (accepted formats : csv, xls, json and h5):
  
      - del Unnamed columns
      - casts lists into variables
      - try to cast variables into float
      - cleans dates and extracts timestamp from 01/01/2017, year, month, day, day_of_week and hour
      - drop duplicates (if drop_duplicate=True)
  
      Parameters
      ----------
      path : str
          The path to the dataset.
  
      drop_duplicate: bool, default = False
          If True, drop duplicates when reading each file.
  
      Returns
      -------
      pandas dataframe
          Cleaned dataset.
      """
  
      ##############################################################
      #                           Reading
      ##############################################################
  
      start_time = time.time()
  
      if path is None:
          raise ValueError("You must specify the path to load the data")
  
      else:
          type_doc = path.split(".")[-1]
  
          if type_doc == "csv":
              if self.sep is None:
                  raise ValueError(
                      "You must specify the separator " "for a csv file"
                  )
              else:
                  if self.verbose:
                      print("")
                      print(
                          "reading csv : "
                          + path.split("/")[-1]
                          + " ..."
                      )
                  df = pd.read_csv(
                      path,
                      sep=self.sep,
                      header=self.header,
                      engine="c",
                      error_bad_lines=False,
                  )
  
          elif type_doc == "xls":
              if self.verbose:
                  print("")
                  print("reading xls : " + path.split("/")[-1] + " ...")
              df = pd.read_excel(path, header=self.header)
  
          elif type_doc == "h5":
              if (
                  sys.platform == "win32"
                  and sys.version_info[0] <= 3
                  and sys.version_info[1] <= 5
              ):
                  raise ValueError(
                      "h5 format not supported for python under 3.6 on windows. Please upgrade python"
                  )
              if self.verbose:
                  print("")
                  print(
                      "reading hdf5 : " + path.split("/")[-1] + " ..."
                  )
  
              df = pd.read_hdf(path)
  
          elif type_doc == "json":
              if (
                  sys.platform == "win32"
                  and sys.version_info[0] <= 3
                  and sys.version_info[1] <= 5
              ):
                  raise ValueError(
                      "json format not supported for python under 3.6 on windows. Please upgrade python"
                  )
              if self.verbose:
                  print("")
                  print(
                      "reading json : " + path.split("/")[-1] + " ..."
                  )
  
              df = pd.read_json(path)
  
          else:
              raise ValueError(
                  "The document extension cannot be handled"
              )
  
      # Deleting unknown column
  
      try:
          del df["Unnamed: 0"]
      except:
          pass
  
      ##############################################################
      #             Cleaning lists, floats and dates
      ##############################################################
  
      if self.verbose:
          print("cleaning data ...")
  
      if sys.platform == "win32":
          df = pd.concat(
              [convert_list(df[col]) for col in df.columns], axis=1
          )
          df = pd.concat(
              [convert_float_and_dates(df[col]) for col in df.columns],
              axis=1,
          )
      else:
          df = pd.concat(
              Parallel(n_jobs=-1)(
                  delayed(convert_list)(df[col]) for col in df.columns
              ),
              axis=1,
          )
  
          df = pd.concat(
              Parallel(n_jobs=-1)(
                  delayed(convert_float_and_dates)(df[col])
                  for col in df.columns
              ),
              axis=1,
          )
  
      # Drop duplicates
  
      if drop_duplicate:
          if self.verbose:
              print("dropping duplicates")
          df = df.drop_duplicates()
      else:
          pass
  
      if self.verbose:
          print("CPU time: %s seconds" % (time.time() - start_time))
  
      return df
  
file_path: MLBox/mlbox/preprocessing/reader.py
imports: import sys
  import pickle
  import os
  import time
  import warnings
  import numpy
  import pandas
  from sklearn.preprocessing import LabelEncoder
  from joblib import Parallel, delayed
label_desc: Use image node_id 2 for calling the Reader obj's underlying member method code with example usage: obj.clean(path, drop_duplicate) and returns: df