'Returns a pandas dataframe based on the query object'

def get_df(self, query_obj=None):

    if (not query_obj):
        query_obj = self.query_obj()
    self.error_msg = u''
    self.results = None
    timestamp_format = None
    if (self.datasource.type == u'table'):
        dttm_col = self.datasource.get_col(query_obj[u'granularity'])
        if dttm_col:
            timestamp_format = dttm_col.python_date_format
    self.results = self.datasource.query(query_obj)
    self.query = self.results.query
    self.status = self.results.status
    self.error_message = self.results.error_message
    df = self.results.df
    if ((df is None) or df.empty):
        self.status = utils.QueryStatus.FAILED
        if (not self.error_message):
            self.error_message = u'No    data.'
        return pd.DataFrame()
    else:
        if (DTTM_ALIAS in df.columns):
            if (timestamp_format in (u'epoch_s', u'epoch_ms')):
                df[DTTM_ALIAS] = pd.to_datetime(df[DTTM_ALIAS], utc=False)
            else:
                df[DTTM_ALIAS] = pd.to_datetime(df[DTTM_ALIAS], utc=False, format=timestamp_format)
            if self.datasource.offset:
                df[DTTM_ALIAS] += timedelta(hours=self.datasource.offset)
        df.replace([np.inf, (- np.inf)], np.nan)
        df = df.fillna(0)
    return df
