|
@@ -347,6 +347,9 @@ class MongodbHandler:
|
|
|
|
|
|
if records:
|
|
|
frames.append(pd.DataFrame(records))
|
|
|
+
|
|
|
+ print('Num frames:', len(frames))
|
|
|
+ print('Len on first frame:', len(frames[0]))
|
|
|
return_df = pd.concat(frames, axis=0, sort=False)
|
|
|
|
|
|
if index is not None:
|
|
@@ -406,15 +409,17 @@ class MongodbHandler:
|
|
|
assert(isinstance(collection_name, str)),\
|
|
|
"Parameter 'collection_name' must be a string type"
|
|
|
try:
|
|
|
- data = self._database[collection_name].find({date_label: {'$gt': from_date_value, '$lt': to_date_value}}, {'_id': return_id})
|
|
|
+ query = {date_label: {'$gt': from_date_value, '$lt': to_date_value}}
|
|
|
+ data = self._database[collection_name].find(query, {'_id': return_id})
|
|
|
|
|
|
except Exception as error:
|
|
|
- self._log.log_and_raise_error(('An error occured trying to query data from {}, with query {}: $gt:{}, $lt:{}. \nError:{}').format(collection_name, date_label, from_date_value, to_date_value, error))
|
|
|
+ self._log.log_and_raise_error(('An error occured trying to query data from {}, with query {}. \nError:{}').format(collection_name, query, error))
|
|
|
|
|
|
- if return_as_dataframe:
|
|
|
- return self.convert_mongo_data_into_dataframe(data, index, collection_name)
|
|
|
- else:
|
|
|
- return data
|
|
|
+ if data.collection.count_documents(query) != 0:
|
|
|
+ if return_as_dataframe:
|
|
|
+ return self.convert_mongo_data_into_dataframe(data, index, collection_name)
|
|
|
+ else:
|
|
|
+ return data
|
|
|
|
|
|
def query_oldest_or_newest_date_in_collection(self, collection_name: str, date_label: str, oldest: bool = False):
|
|
|
|