> For the complete documentation index, see [llms.txt](https://larhues-personal-organization.gitbook.io/intro-to-data-visualization/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://larhues-personal-organization.gitbook.io/intro-to-data-visualization/getting-started/data-types/temporal-data.md).

# Temporal Data

Temporal data represents information that varies over time, capturing changes or trends in a phenomenon as it progresses. This data is characterized by timestamps or time intervals, making it ideal for analyzing patterns, seasonality, and trends across different time periods. Examples include stock prices tracked daily, website traffic logged hourly, or climate data recorded annually.&#x20;

In pandas,  temporal data is represented by `Timestamp` and `datetime` data. Temporal data often requires specialized handling, such as converting strings to `datetime` objects, resampling to aggregate data over desired intervals, or dealing with missing timestamps. Visualizing temporal data using line charts, area plots, or time-series heatmaps is essential for identifying key trends and anomalies. In Python, pandas offers robust functionality for managing temporal data, including time-based indexing, filtering, and resampling. Understanding temporal data is critical in fields such as finance, logistics, and environmental science, where decisions often depend on accurate time-based insights and forecasts.

***

### Code Example

How it appears in Pandas:

```
import pandas as pd

data = {
    'Timestamp': ['2023-01-01', '2023-01-02', '2023-01-03']
}

df = pd.DataFrame(data)
df['Timestamp'] = pd.to_datetime(df['Timestamp'])

# Extract day attributes
df['day_of_month'] = df.Timestamp.dt.day
df['day_of_week'] = df.Timestamp.dt.dayofweek
df['day_name'] = df.Timestamp.dt.day_name()
df['day_of_year'] = df.Timestamp.dt.dayofyear

print(df)
```

Output:

```
   Timestamp
0 2023-01-01
1 2023-01-02
2 2023-01-03
```
