Skip to content

Commit 4bc4e80

Browse files
committed
Merge commit 'v0.12.0rc1-90-g4c2d050' into debian
* commit 'v0.12.0rc1-90-g4c2d050': DOC: add v0.13.0.txt release notes file (but not to the index yet) TST: no need for flavor testing in skip BUG: remove six import BLD: use mpl 1.1.1 in python 2.7 production travis build ENH: implement non-unique indexing in series (GH4246) DOC: Fix typos in CONTRIBUTING.md
2 parents 09d13a9 + 4c2d050 commit 4bc4e80

File tree

11 files changed

+64
-21
lines changed

11 files changed

+64
-21
lines changed

CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
###Guidelines
22

3-
All contributions, bug reports, bug fixes, documentation improvments,
3+
All contributions, bug reports, bug fixes, documentation improvements,
44
enhancements and ideas are welcome.
55

66
The Github "issues" tab contains some issues labels "Good as first PR", these are
@@ -34,7 +34,7 @@ your contribution or address the issue you're having.
3434
See the "Getting Travis-CI going" below.
3535
- We suggest you enable Travis-CI on your fork, to make it easier for the team
3636
to see that the PR does indeed pass all the tests.
37-
- Back-compatiblitiy **really** matters. Pandas already has a large user-base and
37+
- Back-compatibility **really** matters. Pandas already has a large user-base and
3838
a lot of existing user code. Don't break old code if you can avoid it
3939
Explain the need if there is one in the PR.
4040
Changes to method signatures should be made in a way which doesn't break existing
@@ -113,7 +113,7 @@ page for any PR you submit. For example:
113113
114114
See the Green "Good to merge!" banner? that's it.
115115
116-
This is especially important for new contributors, as memebers of the pandas dev team
116+
This is especially important for new contributors, as members of the pandas dev team
117117
like to know the test suite passes before considering it for merging.
118118
Even regular contributors who test religiously on their local box (using tox
119119
for example) often rely on a PR+travis=green to make double sure everything

ci/requirements-2.7.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cython==0.19.1
66
bottleneck==0.6.0
77
numexpr==2.1
88
tables==2.3.1
9-
matplotlib==1.2.1
9+
matplotlib==1.1.1
1010
openpyxl==1.6.2
1111
xlrd==0.9.2
1212
patsy==0.1.0

doc/source/release.rst

+1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ pandas 0.12
235235
names (:issue:`3873`)
236236
- Bug in non-unique indexing via ``iloc`` (:issue:`4017`); added ``takeable`` argument to
237237
``reindex`` for location-based taking
238+
- Allow non-unique indexing in series via ``.ix/.loc`` and ``__getitem`` (:issue:`4246)
238239
239240
- Fixed bug in groupby with empty series referencing a variable before assignment. (:issue:`3510`)
240241
- Allow index name to be used in groupby for non MultiIndex (:issue:`4014`)

doc/source/v0.12.0.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ Bug Fixes
437437
names (:issue:`3873`)
438438
- Bug in non-unique indexing via ``iloc`` (:issue:`4017`); added ``takeable`` argument to
439439
``reindex`` for location-based taking
440+
- Allow non-unique indexing in series via ``.ix/.loc`` and ``__getitem`` (:issue:`4246)
440441

441442
- ``DataFrame.from_records`` did not accept empty recarrays (:issue:`3682`)
442443
- ``read_html`` now correctly skips tests (:issue:`3741`)
@@ -462,7 +463,7 @@ Bug Fixes
462463
(:issue:`4089`)
463464
- Fixed bug in ``DataFrame.replace`` where a nested dict wasn't being
464465
iterated over when regex=False (:issue:`4115`)
465-
- Fixed bug in the parsing of microseconds when using the ``format``
466+
- Fixed bug in the parsing of microseconds when using the ``format``
466467
argument in ``to_datetime`` (:issue:`4152`)
467468
- Fixed bug in ``PandasAutoDateLocator`` where ``invert_xaxis`` triggered
468469
incorrectly ``MilliSecondLocator`` (:issue:`3990`)

doc/source/v0.13.0.txt

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. _whatsnew_0130:
2+
3+
v0.13.0 (August ??, 2013)
4+
------------------------
5+
6+
This is a major release from 0.12.0 and includes several new features and
7+
enhancements along with a large number of bug fixes.
8+
9+
API changes
10+
~~~~~~~~~~~
11+
12+
Enhancements
13+
~~~~~~~~~~~~
14+
15+
Bug Fixes
16+
~~~~~~~~~
17+
18+
See the :ref:`full release notes
19+
<release>` or issue tracker
20+
on GitHub for a complete list.

pandas/core/index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ def reindex(self, target, method=None, level=None, limit=None,
928928
if method is not None or limit is not None:
929929
raise ValueError("cannot reindex a non-unique index "
930930
"with a method or limit")
931-
indexer, _ = self.get_indexer_non_unique(target)
931+
indexer, missing = self.get_indexer_non_unique(target)
932932

933933
return target, indexer
934934

pandas/core/indexing.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -481,12 +481,12 @@ def _reindex(keys, level=None):
481481
new_indexer = (Index(cur_indexer) + Index(missing_indexer)).values
482482
new_indexer[missing_indexer] = -1
483483

484-
# need to reindex with an indexer on a specific axis
485-
from pandas.core.frame import DataFrame
486-
if not (type(self.obj) == DataFrame):
487-
raise NotImplementedError("cannot handle non-unique indexing for non-DataFrame (yet)")
484+
# reindex with the specified axis
485+
ndim = self.obj.ndim
486+
if axis+1 > ndim:
487+
raise AssertionError("invalid indexing error with non-unique index")
488488

489-
args = [None] * 4
489+
args = [None] * (2*ndim)
490490
args[2*axis] = new_labels
491491
args[2*axis+1] = new_indexer
492492

pandas/core/reshape.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
import numpy as np
77

8-
import six
9-
108
from pandas.core.series import Series
119
from pandas.core.frame import DataFrame
1210

@@ -691,7 +689,7 @@ def melt(frame, id_vars=None, value_vars=None,
691689
else:
692690
var_name = [frame.columns.name if frame.columns.name is not None
693691
else 'variable']
694-
if isinstance(var_name, six.string_types):
692+
if isinstance(var_name, basestring):
695693
var_name = [var_name]
696694

697695
N, K = frame.shape

pandas/core/series.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,10 @@ def _get_with(self, key):
681681
return self._get_values(key)
682682
else:
683683
try:
684+
# handle the dup indexing case (GH 4246)
685+
if isinstance(key, (list,tuple)):
686+
return self.ix[key]
687+
684688
return self.reindex(key)
685689
except Exception:
686690
# [slice(0, 5, None)] will break if you convert to ndarray,
@@ -2637,8 +2641,13 @@ def reindex(self, index=None, method=None, level=None, fill_value=pa.NA,
26372641
new_index, indexer = self.index.reindex(index, method=method,
26382642
level=level, limit=limit,
26392643
takeable=takeable)
2644+
2645+
# GH4246 (dispatch to a common method with frame to handle possibly duplicate index)
2646+
return self._reindex_with_indexers(new_index, indexer, copy=copy, fill_value=fill_value)
2647+
2648+
def _reindex_with_indexers(self, index, indexer, copy, fill_value):
26402649
new_values = com.take_1d(self.values, indexer, fill_value=fill_value)
2641-
return Series(new_values, index=new_index, name=self.name)
2650+
return Series(new_values, index=index, name=self.name)
26422651

26432652
def reindex_axis(self, labels, axis=0, **kwargs):
26442653
""" for compatibility with higher dims """

pandas/io/tests/test_html.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,17 @@ def _skip_if_no(module_name):
4343
def _skip_if_none_of(module_names):
4444
if isinstance(module_names, basestring):
4545
_skip_if_no(module_names)
46+
if module_names == 'bs4':
47+
import bs4
48+
if bs4.__version__ == LooseVersion('4.2.0'):
49+
raise nose.SkipTest
4650
else:
4751
if not all(_have_module(module_name) for module_name in module_names):
4852
raise nose.SkipTest
53+
if 'bs4' in module_names:
54+
import bs4
55+
if bs4.__version__ == LooseVersion('4.2.0'):
56+
raise nose.SkipTest
4957

5058

5159
DATA_PATH = get_data_path()
@@ -82,10 +90,6 @@ def run_read_html(self, *args, **kwargs):
8290

8391
def try_skip(self):
8492
_skip_if_none_of(('bs4', 'html5lib'))
85-
import bs4
86-
if (bs4.__version__ == LooseVersion('4.2.0') and
87-
self.flavor != ['lxml']):
88-
raise nose.SkipTest
8993

9094
def setup_data(self):
9195
self.spam_data = os.path.join(DATA_PATH, 'spam.html')
@@ -425,7 +429,8 @@ def try_skip(self):
425429
def test_spam_data_fail(self):
426430
from lxml.etree import XMLSyntaxError
427431
spam_data = os.path.join(DATA_PATH, 'spam.html')
428-
self.assertRaises(XMLSyntaxError, self.run_read_html, spam_data, flavor=['lxml'])
432+
self.assertRaises(XMLSyntaxError, self.run_read_html, spam_data,
433+
flavor=['lxml'])
429434

430435
def test_banklist_data_fail(self):
431436
from lxml.etree import XMLSyntaxError

pandas/tests/test_series.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,15 @@ def test_getitem_unordered_dup(self):
788788
self.assert_(np.isscalar(obj['c']))
789789
self.assert_(obj['c'] == 0)
790790

791+
def test_getitem_dups_with_missing(self):
792+
793+
# breaks reindex, so need to use .ix internally
794+
# GH 4246
795+
s = Series([1,2,3,4],['foo','bar','foo','bah'])
796+
expected = s.ix[['foo','bar','bah','bam']]
797+
result = s[['foo','bar','bah','bam']]
798+
assert_series_equal(result,expected)
799+
791800
def test_setitem_ambiguous_keyerror(self):
792801
s = Series(range(10), index=range(0, 20, 2))
793802
self.assertRaises(KeyError, s.__setitem__, 1, 5)
@@ -1141,7 +1150,7 @@ def test_where(self):
11411150
s = Series(np.arange(10))
11421151
mask = s > 5
11431152
self.assertRaises(ValueError, s.__setitem__, mask, ([0]*5,))
1144-
1153+
11451154
def test_where_broadcast(self):
11461155
# Test a variety of differently sized series
11471156
for size in range(2, 6):

0 commit comments

Comments
 (0)