我需要通过列中数组的交集对PySpark数据帧进行分组。例如,从这样的数据框中获取:
shift
结果应为:
key
因为第1行和第3行的值共有1。
交集时有类似分组的方法吗?
预先感谢您提出解决方案的想法和建议。
答案 0 :(得分:-1)
Query autoComplete_search_query = databaseReference.orderByChild("ADDRESS").startAt(searchString).endAt(searchString+"\uf8ff");
FirebaseRecyclerOptions<Inside_location> options=
new FirebaseRecyclerOptions.Builder<Inside_location>()
.setQuery(autoComplete_search_query,Inside_location.class)
.setLifecycleOwner(this)
.build();
adapter = new FirebaseRecyclerAdapter<Inside_location, InsideLocatinViewHolder>(options) {
public long avgRating,sum=0;
@Override
protected void onBindViewHolder(@NonNull final InsideLocatinViewHolder holder, int position, @NonNull final Inside_location model) {
//GET AVG RATING OF HOSTEL
ratingRef.child(adapter.getRef(position).getKey()).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot dataSnapshot1 : dataSnapshot.getChildren()) {
for (DataSnapshot dataSnapshot11 : dataSnapshot1.getChildren()) {
sum += (long) dataSnapshot11.getValue();
}
}
if (dataSnapshot.getChildrenCount() == 0) {
avgRating = 1;
} else {
avgRating = (long) sum / dataSnapshot.getChildrenCount();
}
holder.RATING.setRating(avgRating);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
holder.NAME.setText(model.getNAME());
holder.ADDRESS.setText(model.getADDRESS());
holder.PRICE.setText("INR "+model.getPRICE()+"*");
holder.SHARING_TYPE.setText(model.getSHARING_TYPE());
holder.SEX.setText(model.getSEX());
Glide.with(insideHostelList.this).load(model.getPICTURES()).apply(new RequestOptions().override(300,185)).into(holder.PICTURES);
mShimmerViewContainer.stopShimmerAnimation();
mShimmerViewContainer.setVisibility(View.GONE);
final Inside_location clickItem = model;
holder.setItemClickListener(new itemClickListener() {
@Override
public void onClick(View view, int position, boolean isLongClick) {
/// Toast.makeText(insideHostelList.this,""+clickItem.getNAME(),Toast.LENGTH_LONG).show();
Intent intent = new Intent(insideHostelList.this,hostelDetails.class);
intent.putExtra("insideHostelID",adapter.getRef(position).getKey());
startActivity(intent);
hostelIdforSelectedRoom = adapter.getRef(position).getKey();
double x = (double) model.getDOUBLE_ROOM_AVAILABLE()/2;
numberOfDoubleRoom= (int)Math.ceil(x);
numberOfSinlgeRoom=model.getSINGLE_ROOM_AVAILABLE();
bookedRoomPrice= model.getPRICE();
bookedRoomAddress=model.getADDRESS();
bookedHostelName = model.getNAME();
AvailableRoomTypes=model.getSHARING_TYPE();
// Toast.makeText(insideHostelList.this,"db room:"+model.getDOUBLE_ROOM_AVAILABLE(),Toast.LENGTH_LONG).show();
// Toast.makeText(insideHostelList.this,"si room:"+model.getSINGLE_ROOM_AVAILABLE(),Toast.LENGTH_LONG).show();
}
});
}
@NonNull
@Override
public InsideLocatinViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.insidecardview, viewGroup, false);
return new InsideLocatinViewHolder(view);
}
};
// Log.d("TAG",""+adapter.getItemCount());
recyclerView.setAdapter(adapter);
}