答案 0 :(得分:1)
如果public static class Pair<F, S> {
private F first;
private S second;
public Pair(F first, S second) {
this.first = first;
this.second = second;
}
}
public static void main(String[] args) {
// criteria is a function
Function<String, Pair<Boolean, String>> criteria = (x) -> new Pair<>(true, x);
Stream.of(criteria)
.map(func -> func.apply(null))
.filter(result -> !result.first)
.map(result -> result.second)
.collect(Collectors.joining(","));
// criteria is a list
List<Function<String, Pair<Boolean, String>>> criterias = new ArrayList<>();
criterias.stream()
.map(func -> func.apply(null))
.filter(result -> !result.first)
.map(result -> result.second)
.collect(Collectors.joining(","));
}
始终是每组的第一名,则应重复输出中的值:
pre
仅可能将每个组的第一个值替换为空字符串,但会得到混合值-带字符串的数字,因此下一个处理应该是问题:
df['diff'] = df.groupby('IDs')['Response'].transform(lambda x: (x.iat[0] - x).min())
编辑:
df['diff'] = df['diff'].mask(df['diff'].duplicated(), '')