Explorar o código

Update aggregation method to take an argument for setting the index of the dataframe

ogert %!s(int64=5) %!d(string=hai) anos
pai
achega
a24c482611
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      cdplib/db_handlers/MongodbHandler.py

+ 2 - 2
cdplib/db_handlers/MongodbHandler.py

@@ -261,14 +261,14 @@ class MongodbHandler:
 
         return self.convert_mongo_data_into_dataframe(data, index)
 
-    def aggregate_data_and_generate_dataframe(self, collection_name: str, aggregation_pipeline: list):
+    def aggregate_data_and_generate_dataframe(self, collection_name: str, aggregation_pipeline: list, index: str = None):
 
         try:
             data = self._database[collection_name].aggregate(pipeline=aggregation_pipeline, allowDiskUse=True)
         except Exception as error:
             self._log.log_and_raise_error(('A problem occured when aggregating the collection {} with the pipeline {}. \nError: {}').format(collection_name, aggregation_pipeline, error))
 
-        return self.convert_mongo_data_into_dataframe(data)
+        return self.convert_mongo_data_into_dataframe(data, index)
 
     def convert_mongo_data_into_dataframe(self, data, index: str = None) -> pd.DataFrame():