|
29 | 29 | from pandas._typing import (
|
30 | 30 | AnyArrayLike,
|
31 | 31 | ArrayLike,
|
32 |
| - DtypeObj, |
33 | 32 | IndexLabel,
|
34 | 33 | JoinHow,
|
35 | 34 | MergeHow,
|
|
48 | 47 | from pandas.core.dtypes.base import ExtensionDtype
|
49 | 48 | from pandas.core.dtypes.cast import find_common_type
|
50 | 49 | from pandas.core.dtypes.common import (
|
51 |
| - ensure_float64, |
52 | 50 | ensure_int64,
|
53 | 51 | ensure_object,
|
54 | 52 | is_bool,
|
@@ -1860,23 +1858,6 @@ def _asof_by_function(direction: str):
|
1860 | 1858 | return getattr(libjoin, name, None)
|
1861 | 1859 |
|
1862 | 1860 |
|
1863 |
| -_type_casters = { |
1864 |
| - "int64_t": ensure_int64, |
1865 |
| - "double": ensure_float64, |
1866 |
| - "object": ensure_object, |
1867 |
| -} |
1868 |
| - |
1869 |
| - |
1870 |
| -def _get_cython_type_upcast(dtype: DtypeObj) -> str: |
1871 |
| - """Upcast a dtype to 'int64_t', 'double', or 'object'""" |
1872 |
| - if is_integer_dtype(dtype): |
1873 |
| - return "int64_t" |
1874 |
| - elif is_float_dtype(dtype): |
1875 |
| - return "double" |
1876 |
| - else: |
1877 |
| - return "object" |
1878 |
| - |
1879 |
| - |
1880 | 1861 | class _AsOfMerge(_OrderedMerge):
|
1881 | 1862 | _merge_type = "asof_merge"
|
1882 | 1863 |
|
@@ -2176,23 +2157,28 @@ def injection(obj: ArrayLike):
|
2176 | 2157 | if len(left_by_values) == 1:
|
2177 | 2158 | lbv = left_by_values[0]
|
2178 | 2159 | rbv = right_by_values[0]
|
| 2160 | + |
| 2161 | + # TODO: conversions for EAs that can be no-copy. |
| 2162 | + lbv = np.asarray(lbv) |
| 2163 | + rbv = np.asarray(rbv) |
2179 | 2164 | else:
|
2180 | 2165 | # We get here with non-ndarrays in test_merge_by_col_tz_aware
|
2181 | 2166 | # and test_merge_groupby_multiple_column_with_categorical_column
|
2182 | 2167 | lbv = flip(left_by_values)
|
2183 | 2168 | rbv = flip(right_by_values)
|
| 2169 | + lbv = ensure_object(lbv) |
| 2170 | + rbv = ensure_object(rbv) |
2184 | 2171 |
|
2185 |
| - # upcast 'by' parameter because HashTable is limited |
2186 |
| - by_type = _get_cython_type_upcast(lbv.dtype) |
2187 |
| - by_type_caster = _type_casters[by_type] |
2188 | 2172 | # error: Incompatible types in assignment (expression has type
|
2189 |
| - # "ndarray[Any, dtype[generic]]", variable has type |
2190 |
| - # "List[Union[Union[ExtensionArray, ndarray[Any, Any]], Index, Series]]") |
2191 |
| - left_by_values = by_type_caster(lbv) # type: ignore[assignment] |
| 2173 | + # "Union[ndarray[Any, dtype[Any]], ndarray[Any, dtype[object_]]]", |
| 2174 | + # variable has type "List[Union[Union[ExtensionArray, |
| 2175 | + # ndarray[Any, Any]], Index, Series]]") |
| 2176 | + right_by_values = rbv # type: ignore[assignment] |
2192 | 2177 | # error: Incompatible types in assignment (expression has type
|
2193 |
| - # "ndarray[Any, dtype[generic]]", variable has type |
2194 |
| - # "List[Union[Union[ExtensionArray, ndarray[Any, Any]], Index, Series]]") |
2195 |
| - right_by_values = by_type_caster(rbv) # type: ignore[assignment] |
| 2178 | + # "Union[ndarray[Any, dtype[Any]], ndarray[Any, dtype[object_]]]", |
| 2179 | + # variable has type "List[Union[Union[ExtensionArray, |
| 2180 | + # ndarray[Any, Any]], Index, Series]]") |
| 2181 | + left_by_values = lbv # type: ignore[assignment] |
2196 | 2182 |
|
2197 | 2183 | # choose appropriate function by type
|
2198 | 2184 | func = _asof_by_function(self.direction)
|
|
0 commit comments