# TableStructure

This metric measures whether the synthetic data captures the same table structure as the real data. We expect the synthetic data to have the same column names as the real data, and for those columns to have the same data storage type (ints, strings, etc.).

## Data Compatibility

* **Any data**: This metric captures the column names in all columns

## Score

**(best) 1.0**: The synthetic data has the same column names as the real data

**(worst) 0.0**: There is no overlap in columns between the real and synthetic data

## How does it work?

This metric identifies all the columns names in the real data (*r)* and the synthetic data (*s)*. The final score is based on the overlap between the columns of these datasets.

$$
score = \frac{|r \cap s|}{|r \cup s|}
$$

Starting from SDV 0.16.0: In the numerator, we consider a column as overlapping if it has the same name *and the same pandas dtype*. In the denominator, we will consider all combinations of (column name, dtype) that appear across the real and synthetic data.

## Usage

Access this metric from the `single_table` module and use the `compute` method.

```python
from sdmetrics.single_table import TableStructure

TableStructure.compute(
    real_data=real_table,
    synthetic_data=synthetic_table
)
```

**Parameters**

* (required) `real_data`: A pandas.DataFrame containing real columns
* (required) `synthetic_data`: A similar pandas.DataFrame containing synthetic columns


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sdv.dev/sdmetrics/data-metrics/diagnostic/tablestructure.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
