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

Bad type hint for argument unique for DataFrameSchema #1760

Open
2 of 3 tasks
sidpatelgit opened this issue Jul 24, 2024 · 1 comment
Open
2 of 3 tasks

Bad type hint for argument unique for DataFrameSchema #1760

sidpatelgit opened this issue Jul 24, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@sidpatelgit
Copy link

sidpatelgit commented Jul 24, 2024

Describe the bug

DataFrameSchema says it accepts str for the argument unique, but if a string is provided, the validation crashes with ValueError: not enough values to unpack (expected 2, got 0).

Might be related to this issue.

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of pandera.
  • (optional) I have confirmed this bug exists on the main branch of pandera.

Code Sample, a copy-pastable example

import pandera as pa
import pandas as pd

df = pd.DataFrame({'alpha':[0,1],'beta':[2,3]})
schema = pa.DataFrameSchema(columns={'alpha':pa.Column(dtype=int),'beta':pa.Column(dtype=int)},unique='alpha',strict=True)
schema.validate(df)

If you change alpha in the example to a, it seems to work. So maybe the problem is strings with more than one character.

Expected behavior

If the type hint says it accept str, then if I provide str, the validation should run without crashing.

Desktop (please complete the following information):

  • OSX 14.4 (23E214)
  • Browser: chrome
@sidpatelgit sidpatelgit added the bug Something isn't working label Jul 24, 2024
@Jarek-Rolski
Copy link
Contributor

I created pull request fixing the issue. #1817

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

2 participants