fix_pandas_dataframe.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:Eskapade 作者: KaveIO 项目源码 文件源码
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]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号