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

Synthesizers crash when column names are integers (TypeError: unsupported operand) #1935

Closed
npatki opened this issue Apr 18, 2024 · 0 comments · Fixed by #1976
Closed

Synthesizers crash when column names are integers (TypeError: unsupported operand) #1935

npatki opened this issue Apr 18, 2024 · 0 comments · Fixed by #1976
Assignees
Labels
bug Something isn't working
Milestone

Comments

@npatki
Copy link
Contributor

npatki commented Apr 18, 2024

Environment Details

  • SDV version: 1.12.0

Error Description

If my datafame's column names are represented with integers (instead of with strings), then the synthesizer's fit crashes with a TypeError

Steps to reproduce

import pandas as pd
import numpy as np

from sdv.metadata import SingleTableMetadata
from sdv.single_table import GaussianCopulaSynthesizer

# generate a dataframe with integer column names
num_rows = 100
num_cols = 20
values = {i+1: np.random.randint(0, 100, size=num_rows) for i in range(num_cols)}
data = pd.DataFrame(values)

# create metadata
metadata = SingleTableMetadata()
metadata_dict = {'columns': {}}
for i in range(num_cols):
  metadata_dict['columns'][i+1] = { 'sdtype': 'numerical' }
metadata = SingleTableMetadata.load_from_dict(metadata_dict)

# try to model it
synth = GaussianCopulaSynthesizer(metadata)
synth.fit(data)
TypeError: unsupported operand type(s) for +=: 'int' and 'str'

stack_trace.txt

Additional Context

df = pd.read_csv('my_data.csv', header=None)

Workaround

A simple workaround would be to rename the columns using strings instead of integers.

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
3 participants