-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
6366bf0
commit fd63c90
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,43 @@ | ||
# coding=utf-8 | ||
# pylint: disable-msg=E1101,W0612 | ||
|
||
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.