@@ -332,10 +332,12 @@ def _group_by_sort_key(x):
332332 }
333333 self .hashes = dict_ () if hashes is None else hashes
334334 self ._numpy_paths = dict_ () # if _numpy_paths is None else _numpy_paths
335+ self .group_by_keys = set () # Track keys that originated from group_by operations
335336 self ._shared_parameters = {
336337 'hashes' : self .hashes ,
337338 '_stats' : self ._stats ,
338339 '_distance_cache' : self ._distance_cache ,
340+ 'group_by_keys' : self .group_by_keys ,
339341 '_numpy_paths' : self ._numpy_paths ,
340342 _ENABLE_CACHE_EVERY_X_DIFF : self .cache_tuning_sample_size * 10 ,
341343 }
@@ -599,13 +601,21 @@ def _get_clean_to_keys_mapping(self, keys, level):
599601 elif self .use_enum_value and isinstance (key , Enum ):
600602 clean_key = key .value
601603 elif isinstance (key , numbers ):
602- type_ = "number" if self .ignore_numeric_type_changes else key .__class__ .__name__
603- if self .significant_digits is None :
604- clean_key = key
604+ # Skip type prefixing for keys that originated from group_by operations
605+ if hasattr (self , 'group_by_keys' ) and key in self .group_by_keys :
606+ if self .significant_digits is None :
607+ clean_key = key
608+ else :
609+ clean_key = self .number_to_string (key , significant_digits = self .significant_digits ,
610+ number_format_notation = self .number_format_notation )
605611 else :
606- clean_key = self .number_to_string (key , significant_digits = self .significant_digits ,
607- number_format_notation = self .number_format_notation )
608- clean_key = KEY_TO_VAL_STR .format (type_ , clean_key )
612+ type_ = "number" if self .ignore_numeric_type_changes else key .__class__ .__name__
613+ if self .significant_digits is None :
614+ clean_key = key
615+ else :
616+ clean_key = self .number_to_string (key , significant_digits = self .significant_digits ,
617+ number_format_notation = self .number_format_notation )
618+ clean_key = KEY_TO_VAL_STR .format (type_ , clean_key )
609619 else :
610620 clean_key = key
611621 if self .ignore_string_case and isinstance (clean_key , str ):
@@ -1845,8 +1855,14 @@ def _group_iterable_to_dict(self, item, group_by, item_name):
18451855 for row in item_copy :
18461856 if isinstance (row , Mapping ):
18471857 key1 = self ._get_key_for_group_by (row , group_by_level1 , item_name )
1858+ # Track keys created by group_by to avoid type prefixing later
1859+ if hasattr (self , 'group_by_keys' ):
1860+ self .group_by_keys .add (key1 )
18481861 if group_by_level2 :
18491862 key2 = self ._get_key_for_group_by (row , group_by_level2 , item_name )
1863+ # Track level 2 keys as well
1864+ if hasattr (self , 'group_by_keys' ):
1865+ self .group_by_keys .add (key2 )
18501866 if key1 not in result :
18511867 result [key1 ] = {}
18521868 if self .group_by_sort_key :
0 commit comments