Skip to content

[ENH] Automatically convert non-string categorical data in attributes_arff_from_df #1489

Open

Description

@alphaleporus

Is your feature request related to a problem? Please describe.
Currently, attributes_arff_from_df raises a ValueError if a pandas DataFrame contains a categorical column with non-string values (e.g., integers [0, 1]). The user is forced to manually cast these to strings before passing the DataFrame.

Describe the solution you'd like
Instead of raising an error immediately, the function should attempt to automatically convert the categories to strings using .astype(str). This improves UX for users working with mixed-type or integer-encoded categorical data.

Describe alternatives you've considered
Keep raising the error, but improve the message. However, automatic conversion is more user-friendly as ARFF expects string nominals anyway.

Additional context
I have a fix implemented locally and can submit a PR.

Activity

  1. alphaleporus commented on Nov 20, 2025

    @alphaleporus
    Author

    PR submitted!

  2. AtharvaManale commented on Oct 13, 2026

    @AtharvaManale

    Hi @PGijsbers,

    I have reviewed the issue and the proposed automatic conversion of non-string categorical labels for #1489, I explored a couple of edge cases and added tests for integer categories and categorical columns containing missing values which the proposed solution by @alphaleporus failed.

    I have raised a pr #1771 which showcases the testcases and what problems the proposed solution creates further.

    Would you recommend keeping the current ValueError behavior for unsupported categorical types, or should we pursue automatic conversion with an explicitly defined policy?

    If the current behavior of returning valueerror is intentional, perhaps the issue could be closed or reframed as an enhancement. I’d appreciate your guidance on the issue and the existing PR.

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

Metadata

Metadata

Assignees

No one assigned

    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