File tree Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ pandas 0.11.1
61
61
- Fix regression in a DataFrame apply with axis=1, objects were not being converted back
62
62
to base dtypes correctly (GH3480 _)
63
63
- Fix issue when storing uint dtypes in an HDFStore. (GH3493 _)
64
+ - Fix assigning a new index to a duplicate index in a DataFrame would fail (GH3468 _)
64
65
65
66
.. _GH3164 : https://github.com/pydata/pandas/issues/3164
66
67
.. _GH3251 : https://github.com/pydata/pandas/issues/3251
@@ -75,6 +76,7 @@ pandas 0.11.1
75
76
.. _GH3455 : https://github.com/pydata/pandas/issues/3455
76
77
.. _GH3457 : https://github.com/pydata/pandas/issues/3457
77
78
.. _GH3461 : https://github.com/pydata/pandas/issues/3461
79
+ .. _GH3468 : https://github.com/pydata/pandas/issues/3468
78
80
.. _GH3448 : https://github.com/pydata/pandas/issues/3448
79
81
.. _GH3449 : https://github.com/pydata/pandas/issues/3449
80
82
.. _GH3493 : https://github.com/pydata/pandas/issues/3493
Original file line number Diff line number Diff line change @@ -56,11 +56,16 @@ def _gi(self, arg):
56
56
@property
57
57
def ref_locs (self ):
58
58
if self ._ref_locs is None :
59
- indexer = self .ref_items .get_indexer (self .items )
60
- indexer = com ._ensure_platform_int (indexer )
61
- if (indexer == - 1 ).any ():
62
- raise AssertionError ('Some block items were not in block '
63
- 'ref_items' )
59
+ ri = self .ref_items
60
+ if ri .is_unique :
61
+ indexer = ri .get_indexer (self .items )
62
+ indexer = com ._ensure_platform_int (indexer )
63
+ if (indexer == - 1 ).any ():
64
+ raise AssertionError ('Some block items were not in block '
65
+ 'ref_items' )
66
+ else :
67
+ indexer = np .arange (len (ri ))
68
+
64
69
self ._ref_locs = indexer
65
70
return self ._ref_locs
66
71
Original file line number Diff line number Diff line change @@ -9201,6 +9201,21 @@ def test_assign_columns(self):
9201
9201
assert_series_equal (self .frame ['C' ], frame ['baz' ])
9202
9202
assert_series_equal (self .frame ['hi' ], frame ['foo2' ])
9203
9203
9204
+ def test_assign_columns_with_dups (self ):
9205
+
9206
+ # GH 3468 related
9207
+ df = DataFrame ([[1 ,2 ]], columns = ['a' ,'a' ])
9208
+ df .columns = ['a' ,'a.1' ]
9209
+
9210
+ expected = DataFrame ([[1 ,2 ]], columns = ['a' ,'a.1' ])
9211
+ assert_frame_equal (df , expected )
9212
+
9213
+ df = DataFrame ([[1 ,2 ]], columns = ['a' ,'a' ])
9214
+ df .columns = ['b' ,'b' ]
9215
+
9216
+ expected = DataFrame ([[1 ,2 ]], columns = ['b' ,'b' ])
9217
+ assert_frame_equal (df , expected )
9218
+
9204
9219
def test_cast_internals (self ):
9205
9220
casted = DataFrame (self .frame ._data , dtype = int )
9206
9221
expected = DataFrame (self .frame ._series , dtype = int )
You can’t perform that action at this time.
0 commit comments