我正在尝试对 Pandas DataFrame 进行以下转换:
源数据帧:
Food Type Eaten 2018-01 Eaten 2018-02 Eaten 2018-03
0 Apple Fruit 3 4 0
1 Pizza Fast Food 2 1 3
2 Cake Desert 3 6 7
Run Code Online (Sandbox Code Playgroud)
目标数据帧:
Food Type Month Eaten
0 Apple Fruit 2018-01 3
1 Apple Fruit 2018-02 4
2 Apple Fruit 2018-03 0
3 Pizza Fast Food 2018-01 2
4 Pizza Fast Food 2018-02 1
5 Pizza Fast Food 2018-03 3
6 Cake Desert 2018-01 3
7 Cake Desert 2018-02 6 …Run Code Online (Sandbox Code Playgroud)