Skip to content

added test case for iloc function if it returns the same output for b… #41028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pandas/tests/indexing/multiindex/test_iloc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import pytest

import pandas as pd
from pandas import (
DataFrame,
MultiIndex,
Expand Down Expand Up @@ -73,6 +74,24 @@ def test_iloc_getitem_multiple_items():
tm.assert_frame_equal(result, expected)


def test_iloc_np_and_pd():
# test if iloc returns the same output for numpy array input and integer array input
df = DataFrame(
data={
"col1": [1, 2, 3, 4],
"col2": [3, 4, 5, 6],
"col3": [6, 7, 8, 9],
}
)
df_np = df
df_pd = df
np_arr = np.array([1, 2, 3])
pd_arr = pd.array([1, 2, 3])
df_np.iloc[[1, 2, 3]] = np_arr
df_pd.iloc[[1, 2, 3]] = pd_arr
tm.assert_frame_equal(df_np, df_pd)


def test_iloc_getitem_labels():
# this is basically regular indexing
arr = np.random.randn(4, 3)
Expand Down
1 change: 1 addition & 0 deletions pip
Submodule pip added at e6a65f