Categorical data records membership in a limited set of named groups rather than a measured quantity. Typical fields include customer location, department, demographics, survey responses, colors, and political parties. A numeric-looking field can still be categorical when its codes stand for groups rather than amounts. section 6.0 section 6.1
Classify categories as nominal when they have no natural order, such as colors, or ordinal when they have an order without meaningful equal spacing, such as sizes or agreement responses. Do not apply continuous-data reasoning—such as averages, correlations, or unit-change interpretations—to arbitrary category codes. section 6.1 section 6.1.1
Work with categorical values by first checking how they are represented, then choosing transformations and comparisons that preserve their meaning:
- Inspect distinct values, missingness, and whether multiple-choice answers are stored together as semicolon-separated strings. section 6.4.1
- Set an explicit order for ordinal categories when ordering affects sorting, display, or analysis. section 5.4.3 section 7.3.1
- Create mutually exclusive binary indicator columns through one-hot encoding when a model requires numeric inputs. section 6.1.1
- Cross-tabulate categorical variables with pivot tables and heatmaps; reshape wide data or split multiple answers when needed. section 7.3.1
- Combine similar categories, bin a continuous value into broader groups when useful, and select statistical tests and visualizations that fit the data types. section 7.3.1 section 7.4
Ordering cinema periods
Monthly admissions can be labeled pre-COVID, during COVID, and post-lockdowns. Treating those labels as an ordered categorical field keeps plots and grouped summaries in chronological order rather than alphabetical order, while a count including missing values checks that every row was assigned. section 5.4.3
Table 6.1 An overview of the different types of data
|
Name
|
Categorical or continuous?
|
Properties
|
Example
|
|---|---|---|---|
|
Nominal
|
Categorical
|
Data has discrete values, and categories are not ordered.
|
Colors, political parties
|
|
Ordinal
|
Categorical
|
Data has discrete values, and categories have a natural order, but spacing is uneven between categories.
|
T-shirt sizes (S/M/L), survey responses (good versus bad)
|
|
Interval
|
Continuous
|
Values are spaced evenly, but zero is not an absence of the measurement.
|
Temperature
|
|
Ratio
|
Continuous
|
Values are spaced evenly, and zero means an absence of the measurement.
|
Height, weight
|
Compare nominal and ordinal categories with interval and ratio measurements before choosing summaries, visualizations, or models. section 6.1















