Skip to content

Investigate erroneous int conversion in MultiIndex #285

Closed
@wesm

Description

@wesm

>> I was just using this feature and noticed a curious behaviour -- if you have dates in the ISO8601 YYYYMMDD format then importing from csv with a MultiIndex turns them into ints, whereas importing with a regular index parses them to dates.
>>
>> Looking at pandas/io/parsers.py (https://github.com/wesm/pandas/commit/1a5a252d97cb3f691a6bf93412b921b085f1be76#L1L113) it seems that the _maybe_convert_int_mindex() method you added prefers ints over dates -- is this intentional or were you just not expecting any overlap between ints and dates?
>>
>
> Most likely the latter.
>
>> You also no longer call _maybe_convert_int, which was previously being called but is now unused, and instead do the int parsing with a map().
>>
>> Why not just implement _maybe_convert_int_mindex() along the lines of what was originally there, something like this:
>>    for i in range(len(index)):
>>        if parse_dates:
>>            index = _try_parse_dates(index[i], parser=date_parser)
>>        index[i] = _maybe_convert_int(np.array(index[i], dtype=object))
>>
>> I would just do it and submit a patch but I just wanted to check with you as you're more familiar with this code since you wrote it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions