forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TST: split series/test_indexing.py (pandas-dev#18614)
- Loading branch information
1 parent
0bfb61b
commit c20f551
Showing
9 changed files
with
2,991 additions
and
2,874 deletions.
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# coding=utf-8 | ||
# pylint: disable-msg=E1101,W0612 | ||
|
||
import pytest | ||
|
||
import numpy as np | ||
|
||
from pandas import Series | ||
|
||
from pandas.compat import lrange, range | ||
from pandas.util.testing import (assert_series_equal, | ||
assert_almost_equal) | ||
|
||
JOIN_TYPES = ['inner', 'outer', 'left', 'right'] | ||
|
||
from pandas.tests.series.common import TestData | ||
|
||
|
||
class TestIloc(TestData): | ||
|
||
def test_iloc(self): | ||
s = Series(np.random.randn(10), index=lrange(0, 20, 2)) | ||
|
||
for i in range(len(s)): | ||
result = s.iloc[i] | ||
exp = s[s.index[i]] | ||
assert_almost_equal(result, exp) | ||
|
||
# pass a slice | ||
result = s.iloc[slice(1, 3)] | ||
expected = s.loc[2:4] | ||
assert_series_equal(result, expected) | ||
|
||
# test slice is a view | ||
result[:] = 0 | ||
assert (s[1:3] == 0).all() | ||
|
||
# list of integers | ||
result = s.iloc[[0, 2, 3, 4, 5]] | ||
expected = s.reindex(s.index[[0, 2, 3, 4, 5]]) | ||
assert_series_equal(result, expected) | ||
|
||
def test_iloc_nonunique(self): | ||
s = Series([0, 1, 2], index=[0, 1, 0]) | ||
assert s.iloc[2] == 2 |
Oops, something went wrong.