original_docstring: Transform the data for final loading.
  
      :param inc_df: Incremental DataFrame.
      :type inc_df: DataFrame
      :param prev_df: Final DataFrame.
      :type prev_df: DataFrame
      :param config: job configuration
      :type config: Dict
      :param logger: Py4j Logger
      :type logger: Py4j.Logger
      :return: Transformed DataFrame.
      :rtype: DataFrame
      
docstring: Transform the data for final loading.
docstring_tokens: Transform the data for final loading .
code: def transform(inc_df: DataFrame, prev_df: DataFrame, config: Dict, logger) -> DataFrame:
      """Transform the data for final loading.
  
      :param inc_df: Incremental DataFrame.
      :type inc_df: DataFrame
      :param prev_df: Final DataFrame.
      :type prev_df: DataFrame
      :param config: job configuration
      :type config: Dict
      :param logger: Py4j Logger
      :type logger: Py4j.Logger
      :return: Transformed DataFrame.
      :rtype: DataFrame
      """
  
      # calculating the metrics
      inc_df: DataFrame = (inc_df.groupBy('email').count().
                           select(['email',
                                   col('count').alias('page_view'),
                                   lit(config['process_date']).alias('last_active')
                                   ])
                           )
  
      # merging the data with historical records
      df_transformed: DataFrame = (inc_df.join(prev_df,
                                               inc_df.email == prev_df.email,
                                               'full').
                                   select([coalesce(prev_df.email, inc_df.email).
                                          alias('email'),
                                           (coalesce(prev_df.page_view, lit(0))
                                            +
                                            coalesce(inc_df.page_view, lit(0))).
                                          alias('page_view'),
                                           coalesce(prev_df.created_date,
                                                    inc_df.last_active).cast('date').
                                          alias('created_date'),
                                           coalesce(inc_df.last_active,
                                                    prev_df.last_active).cast('date').
                                          alias('last_active')
                                           ])
                                   )
  
      return df_transformed
code_tokens: def transform ( inc_df : DataFrame , prev_df : DataFrame , config : Dict , logger ) -> DataFrame : inc_df : DataFrame = ( inc_df . groupBy ( 'email' ) . count ( ) . select ( [ 'email' , col ( 'count' ) . alias ( 'page_view' ) , lit ( config [ 'process_date' ] ) . alias ( 'last_active' ) ] ) ) df_transformed : DataFrame = ( inc_df . join ( prev_df , inc_df . email == prev_df . email , 'full' ) . select ( [ coalesce ( prev_df . email , inc_df . email ) . alias ( 'email' ) , ( coalesce ( prev_df . page_view , lit ( 0 ) ) + coalesce ( inc_df . page_view , lit ( 0 ) ) ) . alias ( 'page_view' ) , coalesce ( prev_df . created_date , inc_df . last_active ) . cast ( 'date' ) . alias ( 'created_date' ) , coalesce ( inc_df . last_active , prev_df . last_active ) . cast ( 'date' ) . alias ( 'last_active' ) ] ) ) return df_transformed
short_docstring: Transform the data for final loading.
short_docstring_tokens: Transform the data for final loading .
comment: """Transform the data for final loading.
  
      :param inc_df: Incremental DataFrame.
      :type inc_df: DataFrame
      :param prev_df: Final DataFrame.
      :type prev_df: DataFrame
      :param config: job configuration
      :type config: Dict
      :param logger: Py4j Logger
      :type logger: Py4j.Logger
      :return: Transformed DataFrame.
      :rtype: DataFrame
      """$SEP$# calculating the metrics$SEP$# merging the data with historical records