File size: 6,078 Bytes
100c616
 
 
0117ebf
 
100c616
0117ebf
 
 
74cb207
100c616
0117ebf
74cb207
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100c616
 
74cb207
100c616
74cb207
 
 
100c616
74cb207
 
 
 
100c616
74cb207
100c616
74cb207
100c616
74cb207
 
 
100c616
74cb207
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100c616
74cb207
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100c616
0117ebf
100c616
74cb207
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100c616
0117ebf
100c616
0117ebf
 
 
100c616
0117ebf
 
 
 
 
74cb207
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
---
license: cc-by-4.0
tags:
- electric-vehicles
- telemetry
- data-engineering
- medallion-architecture
- databricks
- data-quality
- olap
size_categories:
- 100K<n<1M
configs:
- config_name: messy_stream_2024
  data_files: 1_car_telemetry_2024.csv
- config_name: charging_sessions
  data_files: 2_charging_sessions.csv
- config_name: grid_carbon
  data_files: 3_grid_carbon_hourly.csv
- config_name: archive_rare_user
  data_files: archive_2020_2024_rare_user.csv
- config_name: archive_daily_user
  data_files: archive_2020_2024_daily_user.csv
- config_name: archive_moderate_user
  data_files: archive_2020_2024_moderate_user.csv
- config_name: archive_heavy_user
  data_files: archive_2020_2024_heavy_user.csv
---

# ⚡ EV Fleet Sensor Data — Databricks Medallion Case Study

Raw source CSVs for an end-to-end **Databricks medallion architecture** (Bronze → Silver → Gold) case study:
a deliberately messy EV sensor stream is cleaned, quality-gated, and distilled into decision-grade insights —
battery health ranking, DTC risk, charger siting, and a clean-charging window.

- **Question data:** `1_car_telemetry_2024.csv` — 35,363 rows of 2024 telemetry with **planted faults**
- **Answer key:** the four `archive_2020_2024_*.csv` files — a clean ~175K-row sensor archive (2020–2024)
- The messy 2024 stream was **derived from the archive** (faults planted, seed = 7), so every fault is verifiable.
  The two sources intentionally overlap in 2024 (stream = question, archive = ground truth).

## Dataset Structure

### 🔴 Feed 1 — Car telemetry (the messy stream)

**`1_car_telemetry_2024.csv`** — hourly readings, 4 vehicles, calendar year 2024.

| Column | Type | Description |
|---|---|---|
| `timestamp` | datetime | Hour of reading |
| `vehicle_id` | string | `EV-101` … `EV-104` |
| `user_profile` | string | `rare_user` / `daily_user` / `moderate_user` / `heavy_user` |
| `district` | string | Home district: University, Downtown, Harbor, Industrial |
| `SOC` | float | State of charge, % |
| `SOH` | float | State of health (battery), % |
| `Charging_Cycles` | int | Lifetime charge cycles |
| `charging_now` | int | 0/1 — currently charging |
| `Battery_Temp` | float | Battery temperature, °C |
| `Motor_RPM` | int | Motor speed |
| `Motor_Torque` | float | Motor torque, Nm |
| `Motor_Temp` | float | Motor temperature, °C |
| `Brake_Pad_Wear` | float | Brake pad wear, % |
| `Charging_Voltage` | float | Charging voltage, V |
| `Tire_Pressure` | float | Tire pressure — ⚠️ planted unit faults (kPa vs PSI) |
| `DTC` | int | 1 = diagnostic trouble code active |
| `grid_carbon_g_per_kwh` | float | Grid carbon intensity at that hour |

**Planted fault census:** exact duplicates (419, to be dropped), kPa→PSI unit errors (fix),
out-of-bounds values (fix + flag), missing readings (flag). Silver-layer policy:
*only duplicates die — the row always survives; the faulty value is nulled.*

### 🔌 Feed 2 — Charging sessions

**`2_charging_sessions.csv`** — 484 completed sessions.

| Column | Description |
|---|---|
| `session_id`, `station_id` | Identifiers |
| `district` | Where the session happened (drives charger-siting analysis) |
| `start_time`, `end_time` | Session window |
| `energy_kwh_source_analog`, `power_kw_analog` | Energy delivered / power draw |
| `soc_start_pct`, `soc_end_pct` | Battery % before → after |
| `battery_kwh`, `vehicle_model` | Vehicle pack size and model |
| `station_temp_c` | Station temperature |
| `status` | Session status |

### ⚡ Feed 3 — Grid carbon intensity

**`3_grid_carbon_hourly.csv`** — 168 rows (7 days × 24 h): `date`, `hour`, `carbon_g_per_kwh`.
Midnight peaks near ~911 gCO₂/kWh; midday (~12:00) drops to ~319.

### 🟢 The clean archive (ground truth)

Four files, one per user profile, each with **43,800 rows** (24 h × 365 d × 5 yrs, 2020–2024):

`archive_2020_2024_{rare,daily,moderate,heavy}_user.csv` — same sensor columns as the stream
(leading index column, no timestamps/district).

| File | Vehicle | Profile |
|---|---|---|
| `archive_2020_2024_rare_user.csv` | Renault Zoe (52 kWh) | EV-101 |
| `archive_2020_2024_daily_user.csv` | Hyundai Ioniq 5 (77 kWh) | EV-103 |
| `archive_2020_2024_moderate_user.csv` | VW ID.4 (82 kWh) | EV-102 |
| `archive_2020_2024_heavy_user.csv` | Ford F-150 Lightning (131 kWh) | EV-104 |

## Example decisions this data supports

Transparent, verifiable arithmetic (no black-box model):

1. **Risk score** = `soh_decay_pct_per_year × 20 + dtc_rate_pct × 10`, thresholds 60 (act) / 30 (watch)
   → EV-102 scores **54.1** (decay 1.958 %/yr + 654 DTC events) → service first
2. **Charger siting** = `total_co2_g ÷ vehicle_days`
   → Industrial district worst at **43,311 gCO₂/vehicle-day** across 86 sessions → site the next charger there
3. **Charging window** = cleanest vs dirtiest hour
   → shift charging to **~12:00**: ~319 vs ~911 gCO₂/kWh (2.86× cleaner, ~592 g saved per kWh shifted)

## How it was used

The files are ingested as-is into a Databricks Free Edition lakehouse:

```
Bronze (raw, immutable)  →  Silver (cleaned, quality gate: 35,363 − 419 dupes = 34,944 rows)
                         →  Gold (6 decision tables: soh_trend, dtc_risk_rank, co2_per_vehicle_day,
                                  grid_carbon_by_district_hour, fleet_worry_list, final_decision)
```

## Usage

```python
from huggingface_hub import hf_hub_download
import pandas as pd

path = hf_hub_download(repo_id="jeyanthiii/sample_ev_data_csv",
                       filename="1_car_telemetry_2024.csv",
                       repo_type="dataset")
df = pd.read_csv(path)
```

## Notes

- Faults are **synthetic and intentional** (teaching/demo dataset); the archive is the reference truth.
- 2024 rows exist in both stream and archive **by design** — that overlap is what makes the quality gate provable.
- Local backup of this folder is kept at `~/Documents/work/temp/cl_demo/data/`.

## License

[CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/) — free to use with attribution.