> For the complete documentation index, see [llms.txt](https://docs.sdv.dev/sdmetrics/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sdv.dev/sdmetrics/data-metrics/diagnostic/tablestructure.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
