How to pivot pandas DataFrame column to create binary “value table”?
问题 I have the following pandas dataframe: import pandas as pd df = pd.read_csv("filename.csv") df A B C D E 0 a 0.469112 -0.282863 -1.509059 cat 1 c -1.135632 1.212112 -0.173215 dog 2 e 0.119209 -1.044236 -0.861849 dog 3 f -2.104569 -0.494929 1.071804 bird 4 g -2.224569 -0.724929 2.234213 elephant ... I would like to create more columns based on the identity of categorical values in column E such that the dataframe looks like this: df A B C D cat dog bird elephant .... 0 a 0.469112 -0.282863 -1