@@ -477,33 +477,41 @@ def get_tree_diff(
477477 # Handle tree structure difference
478478 data_tree = data_path_diff [data_path_diff [indicator_col ] == "left_only" ]
479479 data_tree_other = data_path_diff [data_path_diff [indicator_col ] == "right_only" ]
480- data_tree [moved_ind ] = False
481- data_tree_other [moved_ind ] = False
482480
483- if len (data_tree ) and len (data_tree_other ):
484- # Check for moved from and moved to
485- move_from_condition = data_tree [
486- data_tree [name_col ].isin (set (data_tree_other [name_col ]))
487- ]
488- data_tree .loc [move_from_condition .index , moved_ind ] = True
489- move_to_condition = data_tree_other [
490- data_tree_other [name_col ].isin (set (data_tree [name_col ]))
491- ]
492- data_tree_other .loc [move_to_condition .index , moved_ind ] = True
493-
494- path_move_from = data_tree .set_index (path_col )[[moved_ind ]].to_dict (orient = "index" )
495- path_move_to = data_tree_other .set_index (path_col )[[moved_ind ]].to_dict (
496- orient = "index"
497- )
498-
499- path_move_from_suffix = {
500- path : "-" if not detail else ("moved from" if v [moved_ind ] else "removed" )
501- for path , v in path_move_from .items ()
502- }
503- path_move_to_suffix = {
504- path : "+" if not detail else ("moved to" if v [moved_ind ] else "added" )
505- for path , v in path_move_to .items ()
506- }
481+ if detail :
482+ data_tree [moved_ind ] = False
483+ data_tree_other [moved_ind ] = False
484+
485+ if len (data_tree ) and len (data_tree_other ):
486+ # Check for moved from and moved to
487+ move_from_condition = data_tree [
488+ data_tree [name_col ].isin (set (data_tree_other [name_col ]))
489+ ]
490+ data_tree .loc [move_from_condition .index , moved_ind ] = True
491+ move_to_condition = data_tree_other [
492+ data_tree_other [name_col ].isin (set (data_tree [name_col ]))
493+ ]
494+ data_tree_other .loc [move_to_condition .index , moved_ind ] = True
495+
496+ path_move_from = data_tree .set_index (path_col )[[moved_ind ]].to_dict (
497+ orient = "index"
498+ )
499+ path_move_to = data_tree_other .set_index (path_col )[[moved_ind ]].to_dict (
500+ orient = "index"
501+ )
502+ path_move_from_suffix = {
503+ path : "moved from" if v [moved_ind ] else "removed"
504+ for path , v in path_move_from .items ()
505+ }
506+ path_move_to_suffix = {
507+ path : "moved to" if v [moved_ind ] else "added"
508+ for path , v in path_move_to .items ()
509+ }
510+ else :
511+ path_move_from_suffix = dict (zip (data_tree [path_col ], "-" * len (data_tree )))
512+ path_move_to_suffix = dict (
513+ zip (data_tree_other [path_col ], "+" * len (data_tree_other ))
514+ )
507515
508516 # Check tree attribute difference
509517 path_attr_diff : Dict [str , Dict [str , Any ]] = {}
0 commit comments