from datetime import datetime


def process_datetime(datetime_columns):
    """
    Change Datetime to date and time values, set those values as columns, and
    set original datetime column as index
    :param datetime_columns: columns which needs to be converted to Pandas DateTime module
    :return: Modified columns with category having 'DateTime' which can be used for model building
    """
    datetime_columns['datetime'] = datetime_columns['datetime'].apply(lambda x: datetime.strptime(x, '%Y-%m-%d'))
    datetime_columns['year'] = datetime_columns.datetime.apply(lambda x: x.year)
    datetime_columns['month'] = datetime_columns.datetime.apply(lambda x: x.month)
    datetime_columns['day'] = datetime_columns.datetime.apply(lambda x: x.day)
    datetime_columns['hour'] = datetime_columns.datetime.apply(lambda x: x.hour)
    datetime_columns['weekday'] = datetime_columns.datetime.apply(lambda x: x.weekday())
    datetime_columns.set_index('datetime', inplace=True)
    return datetime_columns