![](/img/trans.png)
[英]How to compare values in pandas pivot_table with different indices?
[英]Pandas Pivot_table with different dtype values
我在pivot_table中有一個特別奇怪的行為(或者至少我認為是...)
我從數據庫中提取了一個dataframe
,其中包含與dataframe
透視表一起使用以執行一些基本統計信息的日期:
pd.pivot_table(df,values["Diff_DGach_Dcent","Diff_DepCh_BoxPlt","Attente_totale"],
index=['id_chantier',"date_bl"], aggfunc=np.sum,fill_value=0)
我可以在這些字段上使用數據透視表,但是如果我還將fied“ Cpt”添加到值(這是一個簡單的int字段,其中包含1)以計算數據透視表分組了多少行,則只會顯示Cpt字段,但不再是timedelta的...
是否可以在不同的dtype上執行數據透視表?
編輯:要處理的數據樣本
Diff_DGach_Dcent Diff_DepCh_BoxPlt Attente_totale Cpt
00:21:00 00:45:00 01:23:00 1
00:26:00 00:18:00 02:16:00 1
00:15:00 00:18:00 01:25:00 1
00:25:00 00:18:00 01:25:00 1
00:26:00 00:10:00 01:20:00 1
00:20:00 00:14:00 01:38:00 1
您應該設置columns
參數以指定要對values
進行分組的組。
你有樣本數據嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.