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

Metadata detection crashes when the column names are integers (AttributeError: 'int' object has no attribute 'lower') #1933

Closed
npatki opened this issue Apr 18, 2024 · 0 comments · Fixed by #1989
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 (latest)

Error Description

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

Steps to reproduce

import pandas as pd
import numpy as np

from sdv.metadata import SingleTableMetadata

# 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)

metadata = SingleTableMetadata()
metadata.detect_from_dataframe(data=df)
AttributeError: 'int' object has no attribute 'lower'

stack_trace.txt

Additional Context

When would you have a DataFrame with integer column names? One use case is if I have a CSV that doesn't have any column names listed. If I tell pandas that there is no header in my data, then it will create column names with index values 0, 1, ...

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

Workaround

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

@npatki npatki added the bug Something isn't working label Apr 18, 2024
@npatki npatki changed the title Metadata detection crashes when the column names are integers (TypeError: unsupported operand type(s)) Metadata detection crashes when the column names are integers (AttributeError: 'int' object has no attribute 'lower') Apr 18, 2024
@amontanez24 amontanez24 added this to the 1.12.2 milestone May 13, 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

Successfully merging a pull request may close this issue.

3 participants