From c71be0320f15db5b6827324f432ce2b4774c17e5 Mon Sep 17 00:00:00 2001 From: Liang Yan Date: Sat, 10 Jun 2023 20:09:59 +0800 Subject: [PATCH] TST: Add test for apply cast types GH#9506 Signed-off-by: Liang Yan --- pandas/tests/apply/test_series_apply.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pandas/tests/apply/test_series_apply.py b/pandas/tests/apply/test_series_apply.py index 425d2fb42a711..3e0ff19ae4c1a 100644 --- a/pandas/tests/apply/test_series_apply.py +++ b/pandas/tests/apply/test_series_apply.py @@ -271,6 +271,19 @@ def test_apply_empty_integer_series_with_datetime_index(by_row): tm.assert_series_equal(result, s) +def test_apply_dataframe_iloc(): + uintDF = DataFrame(np.uint64([1, 2, 3, 4, 5]), columns=["Numbers"]) + indexDF = DataFrame([2, 3, 2, 1, 2], columns=["Indices"]) + + def retrieve(targetRow, targetDF): + val = targetDF["Numbers"].iloc[targetRow] + return val + + result = indexDF["Indices"].apply(retrieve, args=(uintDF,)) + expected = Series([3, 4, 3, 2, 3], name="Indices", dtype="uint64") + tm.assert_series_equal(result, expected) + + def test_transform(string_series, by_row): # transforming functions