Pandas dataframe.cut(), but with alphanumeric "ranges"?

Viewed 34

I have a large dataset with a code value:

code line_id etc...
10522 1001 ...
45450 1002 ...
J2122 1003. ...
A1234. 1004. ...

I want to sort it into buckets based on predefined code ranges, similarly to what you'd do with dataframe.cut(). Problem is, some of these codes are alphanumeric. For instance, one of the ranges might be J1000 to J9999 (which would catch line 1003 above.)

Is there a way that cut() can be used with alphanumeric ranges? Or is there a simple method that a relative python/pandas newbie like myself hasn't stumbled upon yet?

0 Answers
Related