liveBook · Manning

Ordinal data

As explained in Effective Data Analysis

Ordinal data consists of observations assigned to categories with a meaningful order but without necessarily equal spacing between categories.

Ordinal data assigns observations to categories with a meaningful order, while the spacing between categories may not be equal. Integer codes can therefore represent ordered categories without making them continuous measurements. section 9.2.1

Treat ordinal variables carefully during exploratory analysis: Pearson correlation may be unreliable, while grouped distributions can reveal useful differences and guide feature selection. section 9.2.1

For comparisons involving ordinal data, rank-based non-parametric tests provide alternatives to distribution-dependent parametric tests:

  • Mann–Whitney U compares two independent samples. section 5.4
  • Wilcoxon signed-rank compares two dependent samples. section 5.4
  • Kruskal–Wallis compares two or more independent samples. section 5.4
  • Friedman compares three or more dependent samples. section 5.4

Calendar features and rat sightings

Deriving month number and day of week from dates creates ordinal predictors. Boxplots show seasonal patterns in rat sightings; weekday grouping reveals fewer reports on weekends, supporting a weekday feature. section 9.2.1

rats_weather["dow"] = rats_weather["day"].dt.dayofweek    #1
rats_weather["month_num"] = rats_weather["day"].dt.month    #2
rats_weather.head()   #3

Inspect the feature-engineering listing that extracts day-of-week and month-number variables from dates. section 9.2.1

How Effective Data Analysis covers it

How deep it goes
Distinguishes ordinal from continuous data and lists rank-based tests, but stops short of detailed test calculations.
Examples
Uses month number, day of week, weekday indicators, rat-sighting boxplots, and date-derived feature columns.
What you can do after
Apply it via grouped distributions, cautious correlation use, and named non-parametric tests for ordinal comparisons.
How it connects
Links ordinal data to categorical data, continuous data, non-parametric tests, ranks, group comparisons, and Pearson correlation.

Also explained in

Compare how 8 books explain ordinal data →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Data Analysis. The section links point to the parts of the book it draws on.