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

Confusing error when passing in an empty dataframe (with constraints) #1455

Closed
npatki opened this issue Jun 1, 2023 · 0 comments · Fixed by #1634
Closed

Confusing error when passing in an empty dataframe (with constraints) #1455

npatki opened this issue Jun 1, 2023 · 0 comments · Fixed by #1634
Assignees
Labels
bug Something isn't working
Milestone

Comments

@npatki
Copy link
Contributor

npatki commented Jun 1, 2023

Problem Description

If I accidentally pass an empty DataFrame into a fit function, I receive an error that doesn't really describe what is happening.

data = pd.DataFrame({'a': [], 'b': [], 'c': []})
metadata = SingleTableMetadata.load_from_dict({
    'columns': {
        'a': { 'sdtype': 'numerical' },
        'b': { 'sdtype': 'numerical' },
        'c': { 'sdtype': 'numerical' }
    }
})
constraint = {
    'constraint_class': 'Inequality',
    'constraint_parameters': {
        'low_column_name': 'a',
        'high_column_name': 'b'
    }
}

synthesizer = GaussianCopulaSynthesizer(metadata)
synthesizer.add_constraints(constraints=[constraint])
synthesizer.fit(data)

Output:

AggregateConstraintsError: 
index 0 is out of bounds for axis 0 with size 0

Expected behavior

The error message should be more explicit.

ValueError: Your dataset is empty.

Context

The error seems to be correct if I do not add any constraints.

data = pd.DataFrame({'a': [], 'b': [], 'c': []})
metadata = SingleTableMetadata.load_from_dict({
    'columns': {
        'a': { 'sdtype': 'numerical' },
        'b': { 'sdtype': 'numerical' },
        'c': { 'sdtype': 'numerical' }
    }
})

synthesizer = GaussianCopulaSynthesizer(metadata)
synthesizer.fit(data)

Output:

ValueError: Your dataset is empty.
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

Successfully merging a pull request may close this issue.

3 participants