2

I have pandas pandas dataframe like this

+-------+-----------+
| Name  | Attribute |
+-------+-----------+
| James | Tall      |
| James | Bald      |
| Lily  | Fat       |
| Lily  | Tall      |
+-------+-----------+

and my expect output is

+------+------+------+-----+
| Name | Tall | Bald | Fat |
+------+------+------+-----+
| James|    1 |    1 |   0 |
| Lily |    1 |    0 |   1 |
+------+------+------+-----+

My data contains several hundred attributes. Does anyone have experience with this kind of transformation?

Dina
  • 146
  • 2
  • 13

0 Answers0