![](/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.