code: def convert_float_and_dates(serie):
      """Converts into float if possible and converts dates.
  
      Creates timestamp from 01/01/2017, year, month, day, day_of_week and hour
  
      Parameters
      ----------
      serie : pandas Serie
          The serie you want to convert
  
      Returns
      -------
      pandas DataFrame
          The converted dataframe
      """
  
      import pandas
  
      # dtype is already a date
  
      if serie.dtype == "datetime64[ns]":
          df = pandas.DataFrame([], index=serie.index)
          df[serie.name + "_TIMESTAMP"] = (
              pandas.DatetimeIndex(serie) - pandas.datetime(2017, 1, 1)
          ).total_seconds()
  
          df[serie.name + "_YEAR"] = pandas.DatetimeIndex(
              serie
          ).year.astype(  # noqa
              float
          )  # TODO: be careful with nan ! object or float ??
  
          df[serie.name + "_MONTH"] = pandas.DatetimeIndex(
              serie
          ).month.astype(  # noqa
              float
          )  # TODO: be careful with nan ! object or float ??
  
          df[serie.name + "_DAY"] = pandas.DatetimeIndex(
              serie
          ).day.astype(
              float
          )  # TODO: be careful with nan ! object or float ??
  
          df[serie.name + "_DAYOFWEEK"] = pandas.DatetimeIndex(
              serie
          ).dayofweek.astype(  # noqa
              float
          )  # TODO: be careful with nan ! object or float ??
  
          df[serie.name + "_HOUR"] = (
              pandas.DatetimeIndex(serie).hour.astype(float)
              + pandas.DatetimeIndex(serie).minute.astype(float) / 60.0
              + pandas.DatetimeIndex(serie).second.astype(float)
              / 3600.0
          )
  
          return df
  
      else:
          # Convert float
  
          try:
              serie = serie.apply(float)
  
          except:
              pass
  
          # Cleaning/converting dates
  
          if serie.dtype != "object":
              return serie
  
          else:
              # trying to cast into date
              df = pandas.DataFrame([], index=serie.index)
  
              try:
                  serie_to_df = pandas.DatetimeIndex(
                      pd.to_datetime(serie)
                  )
  
                  df[serie.name + "_TIMESTAMP"] = (
                      serie_to_df - pandas.datetime(2017, 1, 1)
                  ).total_seconds()
  
                  df[serie.name + "_YEAR"] = serie_to_df.year.astype(
                      float
                  )  # TODO: be careful with nan ! object or float??
  
                  df[serie.name + "_MONTH"] = serie_to_df.month.astype(
                      float
                  )  # TODO: be careful with nan ! object or float??
  
                  df[serie.name + "_DAY"] = serie_to_df.day.astype(
                      float
                  )  # TODO: be careful with nan ! object or float??
  
                  df[
                      serie.name + "_DAYOFWEEK"
                  ] = serie_to_df.dayofweek.astype(
                      float
                  )  # TODO: be careful with nan ! object or float??
  
                  df[serie.name + "_HOUR"] = (
                      serie_to_df.hour.astype(float)
                      + serie_to_df.minute.astype(float) / 60.0
                      + serie_to_df.second.astype(float) / 3600.0
                  )
  
                  return df
  
              except:
                  return serie
  
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 a global function with example usage: convert_float_and_dates(serie) and returns: df, serie, df, serie