def determine_preferred_dtype(dtype_cnt):
"""Determine preferred column data type"""
# get sorted type counts for column
type_cnts = dtype_cnt.most_common()
if not type_cnts:
return None
# determine preferred type from types with the highest count
type_order = {str: '0', np.float64: '1', np.int64: '2', np.bool_: '3'}
return sorted((cnt[0] for cnt in type_cnts if cnt[1] == type_cnts[0][1]),
key=lambda t: type_order.get(t, t.__name__))[0]
评论列表
文章目录