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

SettingWithCopyWarning when conditional sampling #1436

Closed
npatki opened this issue May 18, 2023 · 0 comments · Fixed by #1443
Closed

SettingWithCopyWarning when conditional sampling #1436

npatki opened this issue May 18, 2023 · 0 comments · Fixed by #1443
Assignees
Labels
bug Something isn't working
Milestone

Comments

@npatki
Copy link
Contributor

npatki commented May 18, 2023

When conditional sampling, I continue to get a SettingWithCopyWarning from pandas. It seems to be coming from this line:

sampled[column] = value

Replication

from sdv.datasets.demo import download_demo
from sdv.single_table import GaussianCopulaSynthesizer

data, metadata = download_demo(
    modality='single_table',
    dataset_name='fake_hotel_guests'
)

synthesizer = GaussianCopulaSynthesizer(metadata, enforce_min_max_values=False)
synthesizer.fit(data)

my_condition = Condition(
    num_rows=250,
    column_values={ 'amenities_fee': 100.00 }
)

synthesizer.sample_from_conditions(conditions=[my_condition],
                                   max_tries_per_batch=1,
                                   batch_size=10)
/usr/local/lib/python3.10/dist-packages/sdv/single_table/base.py:548: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  sampled[column] = value
@npatki npatki added the bug Something isn't working label May 18, 2023
@amontanez24 amontanez24 added this to the 1.2.0 milestone Jun 6, 2023
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