import os
import time
import datetime

from . import basic_data


#######################################################################
class DataModification(basic_data.BasicData):
    """
    Make changes to existing dataframe, e.g. swap columns or join dataframes.
    """


    # ----------------------------------------------------------------------
    def show_columns(self):
        """
        Show columns of the dataframe.
        """
        return self.data.columns.tolist()
    
    # ----------------------------------------------------------------------
    def reorder_columns(self, cols):
        """
        Reorder columns in the dataframe.
        """
        self.data = self.data[cols]
    
    # ----------------------------------------------------------------------
    def concat_dataframes(self, df2, subdir=""):
        """
        Concat two dataframes into one.
        """
        self.data = self.data.append(df2, ignore_index=True, sort=False)
        datasets_filepath = os.path.join(self.config.get("datasets_dir"), subdir, self.filename)
        os.makedirs(os.path.dirname(datasets_filepath), exist_ok=True)
        self.save_data_to_disk(datasets_filepath)
    
    # ----------------------------------------------------------------------
    def shuffle_rows(self):
        """
        Random shuffle rows of the dataframe.
        """
        self.data = self.data.sample(frac=1).reset_index(drop=True)
    
    # ----------------------------------------------------------------------
    def drop_columns(self, cols):
        """
        Drop columns from the dataframe.
        """
        for col in cols:
            self.data.drop(col, axis=1, inplace=True)
            
    # ---------------------------------------------------------------------
    def drop_duplicates(self):
        self.data = self.data.drop_duplicates(ignore_index=True)
        
    # ---------------------------------------------------------------------
    def drop_multilevel_domain(self):
        self.data = self.data[~(self.data.domain.str.contains(".", regex=False))]
        self.data.reset_index(drop=True)
    
    # ---------------------------------------------------------------------
    def main(self):
        pass


if __name__ == '__main__':
    pass
