pandas bins dummy 1

pandas bins dummy

>>> dout
   age  ageD_[5, 30]  ageD_(30, 70]  (-inf, 5]  (-inf, 30]  (-inf, 70]  (5, +inf)  (30, +inf)  (70, +inf)
0    5             1              0          1           1           1          0           0           0
1   23             1              0          0           1           1          1           0           0
2   43             0              1          0           0           1          1           1           0
3   70             0              1          0           0           1          1           1           0
4   30             1              0          0           1           1          1           0           0

Here is what the above code is Doing:
1. We create a new column for each bin.
2. We then populate the new columns with a 1 if the value in the original column is in the bin, and 0 otherwise.
3. We then drop the original column.

Similar Posts