例如:
lst = [[ PF2 , E1 , -500, -127, 199971, 200164, True, True],
[ PR2 , E1 , -500, -167, 199655, 200124, True, True],
[ PF2 , E1 , -500, -167, 199645, 200124, False, True],
[ PF2 , E1 , -400, -127, 199971, 200564, True, True],
[ PR2 , E1 , -400, -167, 199155, 200324, True, True]]
df = pd.DataFrame(lst, columns=["Name", "Part", "Rel_s",
"Rel_e", "Abs_s", "Abs_e",
"Quality_Start", "Quality_End"])
I want to modify this dataframe to change the values of Abs_s
to the smallest for each combination of Part
and Rel_s
(and the same thing for Abs_e
with Part
and Rel_e
with the largest value). This part works well with this code:
df[ Abs_s ] = df.groupby(["Part", "Rel_s"])[ Abs_s ].transform( min )
df[ Abs_e ] = df.groupby(["Part", "Rel_e"])[ Abs_e ].transform( max )
如同这一解决办法一样,因为这种办法似乎简单易懂;然而,我也想考虑质量价值,以便我在<条码>、Abs_s值><条码_Start:E1
,-500
, 更正Abs_s
。 页: 1 如果没有良好的质量(<>Tru)值以取代,则应保持Bad Quality(False
)。
我能否补充这些条件? 我如何做这一转变?