例如:如果NaN在qty_min和qty_max列中存在,则需要使用groupby of subj和ffill().bfill()使用fillna()。同样,如果NaN在region_max,region_min中存在,我们需要使用groupby of region和ffill().bfill()来实现fillna()。())
df['qty_max'] = df.groupby(['subj'], sort=False)[
在pandas.fillna中,Method to use forfilling holes in reindexed Series pad / ffill: propagate last valid observation forward to next validbackfill / bfill: use NEXT valid observation to fill
, 6,None],
'Col6' : [3,5,2,5,2,7,9]}) 我想使用jjs in this post here建议的解决方案替换列Col3、Col4和Col5我这样做的方式是 df = df.groupby('Col1')['Col3','Col4','Col5'].ffill().bfill() 但是手动提到列需要做大量的工作。因此,我想知道如何通过切片选择列Col3、Col4和<