> ## Documentation Index
> Fetch the complete documentation index at: https://knowledge.cloudquant.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Aligning Two Datasets Into One

> Strategies for merging two different time series datasets, handling timestamp misalignment, symbol mismatches, and frequency differences.

# Aligning two datasets into one

Merging two different time series datasets into one can be like navigating a minefield — it is one of the trickiest challenges in data science.

## Key challenges

When aligning datasets, you need to consider several critical factors:

1. **Timestamp Availability** — Even if your datasets are timestamped as Daily, you still need to know when the data was available to ensure it can line up.

2. **Symbol Consistency** — Do both datasets contain identical symbols? How do you handle mismatches?

3. **Timeframe Misalignment** — What happens when one dataset operates at 1-minute intervals and another at 5-minute intervals?

4. **Data Expansion Strategy** — When expanding lower-frequency data, should you use first values, last values, or an alternative approach?

5. **Data Aggregation** — When merging in the opposite direction, how do you summarize higher-frequency bars? The choice of average, max, min, or other metrics depends on column content.

## Recommended solution: reindex()

The pandas `reindex()` method allows you to forward fill, back fill, use nearest, or fill with None.

```python theme={null}
df.reindex()
```

<Info>
  For detailed usage, see the [pandas DataFrame.reindex documentation](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.reindex.html).
</Info>

## Alternative: SuperQuery

For datasets within CloudQuant Data Liberator, you can use the **SuperQuery** command to have the system perform the merge automatically. SuperQuery resamples multiple datasets onto a common time axis without manual alignment.

<Tip>
  If both of your datasets are available in CloudQuant Data Liberator, SuperQuery is often the simplest approach — it handles the alignment for you. See the [SuperQuery recipe](/data-science-recipes/superquery) for details.
</Tip>
