BUG: stats: Refactor argument validation to avoid a unicode issue.

Fixes the handling of a unicode argument to the binned statistics
functions.

Closes gh-4026.
Merge pull request #4053 from WarrenWeckesser/binned-stat-str

BUG: stats: Refactor argument validation to avoid a unicode issue.