コード例 #1
0
def native_dtype(np_value: np.ndarray):
    """
    Converts a given numpy scalar to a native python type
    :param np_value: The numpy scalar to be converted
    :type class: '{numpy.ndarray}', required
    """
    try:
        val = np_value.item()
    except AttributeError:
        # Happens when passed a pandas string object or a pandas timestamp object
        try:
            val = np_value.date()
        except AttributeError:
            val = str(np_value)

    return val