@@ -274,31 +274,36 @@ def _generic_metrics(
274274 tmp .append (getattr (calc_period , metric_meth )(** kwargs ))
275275
276276 # Notably for per_group_aai being None:
277- if not tmp :
278- return None
279- tmp = pd .concat (tmp )
280- tmp = tmp .set_index (["date" , "group" , "measure" , "metric" ])
281- tmp = tmp [
282- ~ tmp .index .duplicated (keep = "last" )
283- ] # We want to avoid overlap when more than 2 snapshots
284- tmp = tmp .reset_index ()
285- tmp ["group" ] = tmp ["group" ].fillna (self ._all_groups_name )
286- columns_to_front = ["group" , "date" , "measure" , "metric" ]
287- tmp = tmp [
288- columns_to_front
289- + [
290- col
291- for col in tmp .columns
292- if col not in columns_to_front + ["group" , "risk" , "rp" ]
277+ try :
278+ tmp = pd .concat (tmp )
279+ except ValueError as e :
280+ if str (e ) == "All objects passed were None" :
281+ return None
282+ else :
283+ raise e
284+ else :
285+ tmp = tmp .set_index (["date" , "group" , "measure" , "metric" ])
286+ tmp = tmp [
287+ ~ tmp .index .duplicated (keep = "last" )
288+ ] # We want to avoid overlap when more than 2 snapshots
289+ tmp = tmp .reset_index ()
290+ tmp ["group" ] = tmp ["group" ].fillna (self ._all_groups_name )
291+ columns_to_front = ["group" , "date" , "measure" , "metric" ]
292+ tmp = tmp [
293+ columns_to_front
294+ + [
295+ col
296+ for col in tmp .columns
297+ if col not in columns_to_front + ["group" , "risk" , "rp" ]
298+ ]
299+ + ["risk" ]
293300 ]
294- + ["risk" ]
295- ]
296- setattr (self , attr_name , tmp )
301+ setattr (self , attr_name , tmp )
297302
298- if npv :
299- return self .npv_transform (getattr (self , attr_name ), self .risk_disc )
303+ if npv :
304+ return self .npv_transform (getattr (self , attr_name ), self .risk_disc )
300305
301- return getattr (self , attr_name )
306+ return getattr (self , attr_name )
302307
303308 def _compute_period_metrics (
304309 self , metric_name : str , metric_meth : str , npv : bool = True , ** kwargs
0 commit comments