| 2975 | |
| 2976 | @derived_from(pd.DataFrame) |
| 2977 | def join( |
| 2978 | self, |
| 2979 | other, |
| 2980 | on=None, |
| 2981 | how="left", |
| 2982 | lsuffix="", |
| 2983 | rsuffix="", |
| 2984 | shuffle_method=None, |
| 2985 | npartitions=None, |
| 2986 | ): |
| 2987 | if not isinstance(other, list) and not is_dask_collection(other): |
| 2988 | other = from_pandas(other, npartitions=1) |
| 2989 | if ( |
| 2990 | not isinstance(other, list) |
| 2991 | and not is_dataframe_like(other._meta) |
| 2992 | and hasattr(other._meta, "name") |
| 2993 | ): |
| 2994 | other = new_collection(expr.ToFrame(other)) |
| 2995 | |
| 2996 | if not isinstance(other, FrameBase): |
| 2997 | if not isinstance(other, list) or not all( |
| 2998 | isinstance(o, FrameBase) for o in other |
| 2999 | ): |
| 3000 | raise ValueError("other must be DataFrame or list of DataFrames") |
| 3001 | if how not in ("outer", "left"): |
| 3002 | raise ValueError("merge_multi only supports left or outer joins") |
| 3003 | |
| 3004 | other = [ |
| 3005 | from_pandas(o, npartitions=1) if not is_dask_collection(o) else o |
| 3006 | for o in other |
| 3007 | ] |
| 3008 | |
| 3009 | return new_collection( |
| 3010 | JoinRecursive([self.expr] + [o.expr for o in other], how=how) |
| 3011 | ) |
| 3012 | |
| 3013 | return self.merge( |
| 3014 | right=other, |
| 3015 | left_index=on is None, |
| 3016 | right_index=True, |
| 3017 | left_on=on, |
| 3018 | how=how, |
| 3019 | suffixes=(lsuffix, rsuffix), |
| 3020 | shuffle_method=shuffle_method, |
| 3021 | npartitions=npartitions, |
| 3022 | ) |
| 3023 | |
| 3024 | @derived_from(pd.DataFrame) |
| 3025 | def groupby( |