我有以下数据框
salesman | north_access | south_access | east_access | west_access |
---|---|---|---|---|
A | 1 | 0 | 0 | 1 |
B | 0 | 1 | 1 | 1 |
C | 1 | 0 | 1 | 1 |
我想将上面的格式转换为下面的格式
salesman | direction | access |
---|---|---|
A | north | 1 |
A | south | 0 |
A | east | 0 |
A | west | 1 |
B | north | 0 |
B | south | 1 |
B | east | 1 |
B | west | 1 |
我试着try 拆分和转置功能,但没有得到预期的结果. 有没有人能帮个忙,在代码中做以上的修改,提前谢谢.