MCPcopy Create free account
hub / github.com/dask/dask / test_join_by_index_patterns

Function test_join_by_index_patterns

dask/dataframe/tests/test_multi.py:1195–1315  ·  view source on GitHub ↗
(how, shuffle_method)

Source from the content-addressed store, hash-verified

1193@pytest.mark.slow
1194@pytest.mark.parametrize("how", ["inner", "outer", "left", "right"])
1195def test_join_by_index_patterns(how, shuffle_method):
1196 def fix_index(out, dtype):
1197 # Workaround pandas bug where output dtype of empty index will be int64
1198 # even if input was object.
1199 if len(out) == 0:
1200 return out.set_index(out.index.astype(dtype))
1201 return out
1202
1203 # Similar test cases as test_merge_by_index_patterns,
1204 # but columns / index for join have same dtype
1205
1206 pdf1l = pd.DataFrame(
1207 {"a": list("abcdefg"), "b": [7, 6, 5, 4, 3, 2, 1]}, index=list("abcdefg")
1208 )
1209 pdf1r = pd.DataFrame(
1210 {"c": list("abcdefg"), "d": [7, 6, 5, 4, 3, 2, 1]}, index=list("abcdefg")
1211 )
1212
1213 pdf2l = pdf1l
1214 pdf2r = pd.DataFrame(
1215 {"c": list("gfedcba"), "d": [7, 6, 5, 4, 3, 2, 1]}, index=list("abcdefg")
1216 )
1217
1218 pdf3l = pdf1l
1219 pdf3r = pd.DataFrame({"c": list("abdg"), "d": [5, 4, 3, 2]}, index=list("abdg"))
1220
1221 pdf4l = pd.DataFrame(
1222 {"a": list("abcabce"), "b": [7, 6, 5, 4, 3, 2, 1]}, index=list("abcdefg")
1223 )
1224 pdf4r = pd.DataFrame({"c": list("abda"), "d": [5, 4, 3, 2]}, index=list("abdg"))
1225
1226 # completely different index
1227 pdf5l = pd.DataFrame(
1228 {"a": list("lmnopqr"), "b": [7, 6, 5, 4, 3, 2, 1]}, index=list("lmnopqr")
1229 )
1230 pdf5r = pd.DataFrame({"c": list("abcd"), "d": [5, 4, 3, 2]}, index=list("abcd"))
1231
1232 pdf6l = pd.DataFrame(
1233 {"a": list("cdefghi"), "b": [7, 6, 5, 4, 3, 2, 1]}, index=list("cdefghi")
1234 )
1235 pdf6r = pd.DataFrame({"c": list("abab"), "d": [5, 4, 3, 2]}, index=list("abcd"))
1236
1237 pdf7l = pd.DataFrame(
1238 {"a": list("aabbccd"), "b": [7, 6, 5, 4, 3, 2, 1]}, index=list("abcdefg")
1239 )
1240 pdf7r = pd.DataFrame({"c": list("aabb"), "d": [5, 4, 3, 2]}, index=list("fghi"))
1241
1242 for pdl, pdr in [
1243 (pdf1l, pdf1r),
1244 (pdf2l, pdf2r),
1245 (pdf3l, pdf3r),
1246 (pdf4l, pdf4r),
1247 (pdf5l, pdf5r),
1248 (pdf6l, pdf6r),
1249 (pdf7l, pdf7r),
1250 ]:
1251 for lpart, rpart in [(2, 2), (3, 2), (2, 3)]:
1252 ddl = dd.from_pandas(pdl, lpart)

Callers

nothing calls this directly

Calls 6

assert_eqFunction · 0.90
fix_indexFunction · 0.85
_pandas_joinFunction · 0.85
list_eqFunction · 0.85
joinMethod · 0.45
mergeMethod · 0.45

Tested by

no test coverage detected