Intro to Data Visualization
  • Introduction
  • Getting started
    • Introduction to Pandas
    • Accessing Files on Colab
    • Reviewing Data
      • Understanding type(data) in Pandas
    • Data Types
      • Categorical Data
      • Numeric Data
      • Temporal Data
      • Geographic Data
    • How to Check Data Type
    • Slicing and Subsetting DataFrames
    • Aggregating Data
  • Visualization Types
    • Exploratory Process
    • Explanatory Process
  • data exploration
    • Exploration Overview
    • Exploration with Plotly
      • Exploring Distributions
      • Exploring Relationships
      • Exploring with Regression Plots
      • Exploring Correlations
      • Exploring Categories
      • Exploring Time Series
      • Exploring Stocks with Candlestick
      • Exploring with Facets
      • Exploring with Subplots
    • Exploring with AI
  • Data Explanation
    • Data Explanation with Plotly
      • Using Text
      • Using Annotations
      • Using Color
      • Using Shape
      • Accessibility
      • Using Animations
    • Use Cases
  • Exercises and examples
    • Stock Market
      • Loading Yahoo! Finance Data
      • Use Cases for YF
      • Exploring YF Data
      • Understanding Boeing Data Over Time
      • Polishing the visualization
      • Analyzing with AI
      • Comparisons
    • The Gapminder Dataset
      • Loading the Gapminder Data
      • Use Cases
      • Exploring the Data
      • Exporting a Static Image
Powered by GitBook
On this page
  1. Getting started
  2. Data Types

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.

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
PreviousNumeric DataNextGeographic Data

Last updated 3 months ago