Пример #1
0
    def _get_master(self):
        """ Get the global dataset that will be used for all calculations inside
        this instance of the class

        :return: None
        """
        start_time = time.time()
        start_date, end_date = self._get_date(None,
                                              self.start_date), self._get_date(
                                                  None, self.end_date)
        query = Utilities.open_sql(self.dir_path, 'user_sequence.sql')

        # Temp fix for testing because my credentials are not working
        cache = False
        if cache:
            df = pd.read_csv(
                os.path.join(self.dir_path, 'data/manually_loaded_data',
                             'United Kingdom-Customer Service.csv'))
            print("Converting object types...")
            df = df.astype({'time_event': 'datetime64[ns]'})
            df['time_event'] = df.time_event.apply(
                lambda x: pytz.utc.localize(x))
            df['date'] = df.time_event.dt.date
            self.master = df
        else:
            self.master = self.query_db(query, self._formatted_flow_name(),
                                        start_date.strftime('%Y-%m-%d'),
                                        end_date.strftime('%Y-%m-%d'))
        print(
            f"Master Dataset Gathered in {round(time.time() - start_time, 0)} seconds"
        )
Пример #2
0
 def get_available_flows(self):
     query = Utilities.open_sql(self.dir_path, 'flownames.sql')
     df = self.client.query(query).to_dataframe()
     return df['FlowName'].to_list()