Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to coerce a pandas dataframe col from string to list of string #1834

Open
theoclipse opened this issue Oct 24, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@theoclipse
Copy link

Describe the bug
I am not sure if it is a bug, or it has not been managed since today.

I am using a pandera schema containing following column:

test_col: Series[list[str]] = pa.Field(
        coerce=True,
        description="test column list of string",
    )

It happens that my column (that is tried to be coerce) is a string column:
Example of value: "[]"

When trying to coerce, here is the following error:

Could not coerce <class 'pandas.core.series.Series'> data_container into type list[str]

Expected behavior

I would expect pandera to be able to coerce a string representing a list into a list. With pandas, it is possible like this:

from ast import literal_eval
test_df["test_col"] = test_df["test_col"].apply(literal_eval)

Additional context

Is it a bug or a feature?

Thank you :)

@theoclipse theoclipse added the bug Something isn't working label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant