8000 ENH: indexing and __getitem__ of dataframe and series accept zerodim integer np.array as int by tamuhey · Pull Request #24924 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

ENH: indexing and __getitem__ of dataframe and series accept zerodim integer np.array as int #24924

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

Merged
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
Prev Previous commit
Next Next commit
CLN: remove redundant comment, and name series as s
  • Loading branch information
tamuhey committed Jan 29, 2019
commit 8d4c9a13dab5d70bd33fde32b6ba1be41656ff74
19 changes: 6 additions & 13 deletions pandas/tests/indexing/test_iloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,22 +676,15 @@ def test_identity_slice_returns_new_object(self):
original_series[:3] = [7, 8, 9]
assert all(sliced_series[:3] == [7, 8, 9])

def test_indexing_zero_dim_np_array(self):
def test_indexing_zerodim_np_array(self):
# GH24919
df = DataFrame([[1, 2], [3, 4]])

# should not raise an error
result = df.iloc[np.array(0)]
s = pd.Series([1, 2], name=0)
tm.assert_series_equal(result, s)

# expected series
sr = pd.Series([1, 2], name=0)
tm.assert_series_equal(result, sr)

def test_series_indexing_zero_dim_np_array(self):
def test_series_indexing_zerodim_np_array(self):
# GH24919
sr = Series([1, 2])

# should not raise an error
result = sr.iloc[np.array(0)]

s = Series([1, 2])
result = s.iloc[np.array(0)]
assert result == 1
19 changes: 6 additions & 13 deletions pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,22 +766,15 @@ def test_loc_setitem_empty_append_raises(self):
with pytest.raises(ValueError, match=msg):
df.loc[0:2, 'x'] = data

def test_indexing_zero_dim_np_array(self):
def test_indexing_zerodim_np_array(self):
# GH24924
df = DataFrame([[1, 2], [3, 4]])

# should not raise an error
result = df.loc[np.array(0)]
s = pd.Series([1, 2], name=0)
tm.assert_series_equal(result, s)

# expected series
sr = pd.Series([1, 2], name=0)
tm.assert_series_equal(result, sr)

def test_series_indexing_zero_dim_np_array(self):
def test_series_indexing_zerodim_np_array(self):
# GH24924
sr = Series([1, 2])

# should not raise an error
result = sr.loc[np.array(0)]

s = Series([1, 2])
result = s.loc[np.array(0)]
assert result == 1
0