| 3011 | |
| 3012 | @derived_from(pd.DataFrame) |
| 3013 | def join( |
| 3014 | self, |
| 3015 | other, |
| 3016 | on=None, |
| 3017 | how="left", |
| 3018 | lsuffix="", |
| 3019 | rsuffix="", |
| 3020 | shuffle_method=None, |
| 3021 | npartitions=None, |
| 3022 | ): |
| 3023 | if not isinstance(other, list) and not is_dask_collection(other): |
| 3024 | other = from_pandas(other, npartitions=1) |
| 3025 | if ( |
| 3026 | not isinstance(other, list) |
| 3027 | and not is_dataframe_like(other._meta) |
| 3028 | and hasattr(other._meta, "name") |
| 3029 | ): |
| 3030 | other = new_collection(expr.ToFrame(other)) |
| 3031 | |
| 3032 | if not isinstance(other, FrameBase): |
| 3033 | if not isinstance(other, list) or not all( |
| 3034 | isinstance(o, FrameBase) for o in other |
| 3035 | ): |
| 3036 | raise ValueError("other must be DataFrame or list of DataFrames") |
| 3037 | if how not in ("outer", "left"): |
| 3038 | raise ValueError("merge_multi only supports left or outer joins") |
| 3039 | |
| 3040 | other = [ |
| 3041 | from_pandas(o, npartitions=1) if not is_dask_collection(o) else o |
| 3042 | for o in other |
| 3043 | ] |
| 3044 | |
| 3045 | return new_collection( |
| 3046 | JoinRecursive([self.expr] + [o.expr for o in other], how=how) |
| 3047 | ) |
| 3048 | |
| 3049 | return self.merge( |
| 3050 | right=other, |
| 3051 | left_index=on is None, |
| 3052 | right_index=True, |
| 3053 | left_on=on, |
| 3054 | how=how, |
| 3055 | suffixes=(lsuffix, rsuffix), |
| 3056 | shuffle_method=shuffle_method, |
| 3057 | npartitions=npartitions, |
| 3058 | ) |
| 3059 | |
| 3060 | @derived_from(pd.DataFrame) |
| 3061 | def groupby( |