Browse Source

convert_mongo_data_into_dataframe in MongoHandler added to retrun empty dataframe when data is empty and issue a warning message

tsteuer 4 years ago
parent
commit
7090b423f1
1 changed files with 5 additions and 1 deletions
  1. 5 1
      cdplib/db_handlers/MongodbHandler.py

+ 5 - 1
cdplib/db_handlers/MongodbHandler.py

@@ -343,7 +343,11 @@ class MongodbHandler:
         if len(frames) > 1:
             return_df = pd.concat(frames, axis=0, sort=False)
         else:
-            return_df = frames[0]
+            if not frames:
+                self._log.warning('Query returned empty Cursor')
+                return_df = pd.DataFrame()
+            else:
+                return_df = frames[0]
 
         if index is not None:
             return_df.set_index(index, inplace=True)