> 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 dynamically by asking a question.

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

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
