Skip to content

from_frame(df_with_mixed_str_number_multi_index) broken #1193

@gdementen

Description

@gdementen

The numbers are converted to strings. I noticed initially that that arrays with mixed-type labels do not roundtrip correctly, but this is the root issue. Also adding an explicit test for the roundtrip to HDF would be a good idea though. The bug is probably also present for simple (non-multi) index dataframes and maybe in the sorted case too (I need to test the status of the 4 combinations of simple/multi and sort/no sort).

I discovered this when preparing the 0.35.1 release because I fixed it alongside another issue but I reintroduced the bug on purpose because the demo model relies on the broken behavior and I do not want to knowingly break models in a bugfix release. See inout/pandas.py:simple_index_to_labels()

>>> df = pd.DataFrame([['s0', 'o0', 0], ['s1', 1, 1]], columns=['str', 'obj', 'value']).set_index(['str', 'obj'])
>>> df.index.unique(1)
Index(['o0', 1], dtype='object', name='obj')
>>> from_frame(df).obj.dtype
dtype('<U21')

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions