Python / Pandas - 关于多维数据的透视

时间:2018-03-08 18:36:21

标签: python pandas pivot reshape

我是python / pandas的新手。我正在尝试将行转置为columns.Apologies任何误解 input_df(pic) output_df(pic)

input_df:
Date    Project    Processes                Time_in_sec Time_measures
-----------------------------------------------------------------------
7/6/2017    FE      eBanking .aspx          157         Average Response Time 
9/2/2017    PCB     eBanking Frontpage.fi   227         Call per hour
1/23/2017   ICC     Acct Transfer.dc        28          Average Response Time 
1/24/2017   PCB     Transaction .com        0           Number of calls
1/23/2017   ICC     eBanking Logon.no       0           Number of calls

output_df:
Date    Project Processes   Average Response Time   Call per hour   Number of calls
-----------------------------------------------------------------------------
7/6/2017    FE  eBanking .aspx        157       
9/2/2017    PCB eBanking Frontpage.fi                    227    
1/24/2017   PCB Transaction .com                                        0
1/23/2017   ICC Acct Transfer.dc      28        
1/23/2017   ICC eBanking Logon.no                                       0

我尝试了下面的代码,并在输出below_code's_output中只获得了3个列的“平均响应时间”,“每小时呼叫次数”“呼叫次数”。但我很困惑如何获得所有必要的6列。你能帮忙吗?

    output_df = input_df.pivot(columns = 'Time_measures',  values= 'Time_in_sec')

1 个答案:

答案 0 :(得分:1)

IIUC您可以将 <!DOCTYPE html> <html lang="en"> <head> <script src="http://d3js.org/d3.v3.min.js"></script> <script type="text\javascript" src="jljs.js"></script> <meta charset="utf-8"> </head> <body> <center> <fieldset> <p> Search here: <input type="text" id="txtsearch"/> &nbsp;&nbsp;&nbsp;&nbsp <button onclick="Search()">Find now</button> </p> </fieldset> </center> </body> </html> function Search() { var me = (d3.select("#txtsearch").property("value")); alert(me); }

一起使用
pivot_table