A composite key identifies a record through a combination of columns rather than one ID. It is useful when a single identifier repeats across merged databases or when each observation is defined by several dimensions, such as location, date, hour, and travel direction. section 8.4.1
Establish the intended row granularity before analysis: propose the columns that should make an observation unique, count their distinct combinations, and compare that count with the dataset’s row count. A shortfall means the proposed key omits a distinguishing column or the data contains repeated records. section 8.4.1
Traffic counts by place, time, and direction
For hourly traffic measurements, Count_point_id, Year, Count_date, and hour produce too few distinct combinations. Because the gap is roughly a factor of two, Direction_of_travel is a practical next candidate: traffic may be measured separately in both directions at one location and hour. Remaining duplicate key groups require inspection rather than blind removal, since rows sharing the candidate key can still differ in measurement values. section 8.4.1
len(traffic[["Count_point_id", "Year", "Count_date", "hour", "Direction_of_travel"]].drop_duplicates())
Count distinct candidate-key combinations after adding travel direction, then compare the result with the total row count. section 8.4.1







