Skip to content

Why do empty strings with integers get converted to zero? #203

Open

Description

@flexatone
>>> ak.iterable_str_to_array_1d(['', '3'])
array([0, 3])

>>> ak.iterable_str_to_array_1d(['', '3'], dtype=int)
array([0, 3])

Activity

  1. self-assigned this
    on Feb 3, 2026
  2. flexatone commented on Feb 3, 2026

    @flexatone
    ContributorAuthor

    This happens for two reasons:

    1. AK_UCS4_to_int64, if given all empty field, returns an npy_int64 of 0; this cannot easily return an error code. Also: AK_UCS4_to_uint64 does the same thing.
    2. AK_CPL_current_to_bool, similarly, treats empty or non "true" values as 0.
    3. When auto-type detection is used, it is the logic in AK_TPS_Resolve that, if previous is TPS_INT and new is TPS_EMPTY, we return TPS_INT; this is the same for TPS_FLOAT and TPS_BOOL.
  3. flexatone commented on Feb 5, 2026

    @flexatone
    ContributorAuthor

    This is the same for Boolean arrays, where the default is False:

    >>> ak.iterable_str_to_array_1d(('', 'true'))
    array([False,  True])
  4. flexatone commented on Feb 6, 2026

    @flexatone
    ContributorAuthor

    possible Boolean parameter names, defaulting to True for now

    implicit_empty_int
    implicit_empty_bool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions