Py学习  »  Python

在Python中取消堆栈行标签(透视表)

MarthaF • 4 年前 • 661 次点击  

我想使用Python取消对行标签名称的备份。

已清除数据以删除总计行和na行。

代码的外观:

Description   | Table    |  Chair
***Manila***  |          |   
Apple         |     1    |    3
Pair          |     0    |    1
Orange        |     1    |    0
Watermelon    |     0    |    5
Banana        |     0    |    7
***Quezon***  |          |  
DragonFruit   |     0    |    0
StarApple     |     0    |    0
Longan        |     0    |    1
Cherries      |     1    |    2
Mango         |     0    |    5

表格图像:

how raw data looks like

enter image description here

我希望代码看起来像:

Description  |   Day   |    Table  |  Chair
Manila    |    1     |     1    |   3
Manila    |    2     |     0    |   1
Manila    |    3     |     1    |   0
Manila    |    4     |     0    |   5
Manila    |    5     |     0    |   7
Quezon    |    1     |     0    |   0
Quezon    |    2     |     0    |   0
Quezon    |    3     |     0    |   1
Quezon    |    4     |     1    |   2
Quezon    |    5     |     0    |   5

表格图像: enter image description here

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/50697
 
661 次点击  
文章 [ 2 ]  |  最新文章 4 年前