📌  相关文章
📜  将列转换为行 pandas - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:51.182000             🧑  作者: Mango

代码示例1
df.melt(id_vars=["location", "name"], 
        var_name="Date", 
        value_name="Value")

  location    name        Date  Value
0        A  "test"    Jan-2010     12
1        B   "foo"    Jan-2010     18
2        A  "test"    Feb-2010     20
3        B   "foo"    Feb-2010     20
4        A  "test"  March-2010     30
5        B   "foo"  March-2010     25