room , box_num 第一次 begintime df.groupby().transform() :
room
box_num
begintime
df.groupby().transform()
df['group_num'] = pd.factorize(df['room'].astype(str) + df['box_num'].astype(str) + \ df.groupby('hash')['begintime'].transform(min).astype(str))
ValueError: Length of values does not match length of index
我知道, transform 回报 Series
transform
Series
缺少最后一个 [0] factorize 返回2个数组:
[0]
factorize
df['group_num'] = pd.factorize(df['room'].astype(str) + df['box_num'].astype(str) + \ df.groupby('hash')['begintime'].transform(min).astype(str))[0]