| 34 | |
| 35 | |
| 36 | def _concat(args, ignore_index=False): |
| 37 | if not args: |
| 38 | return args |
| 39 | if isinstance(first(core.flatten(args)), np.ndarray): |
| 40 | return da.core.concatenate3(args) |
| 41 | if not has_parallel_type(args[0]): |
| 42 | try: |
| 43 | return pd.Series(args) |
| 44 | except Exception: |
| 45 | return args |
| 46 | # We filter out empty partitions here because pandas frequently has |
| 47 | # inconsistent dtypes in results between empty and non-empty frames. |
| 48 | # Ideally this would be handled locally for each operation, but in practice |
| 49 | # this seems easier. TODO: don't do this. |
| 50 | args2 = [i for i in args if len(i)] |
| 51 | return ( |
| 52 | args[0] |
| 53 | if not args2 |
| 54 | else methods.concat(args2, uniform=True, ignore_index=ignore_index) |
| 55 | ) |
| 56 | |
| 57 | |
| 58 | def split_evenly(df, k): |