BUG: cant modify df with duplicate index (#17105)
State: closed

- [x] closes #17105
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

Fixing to allow the modification of DataFrames that have duplicate elements in the index. Previously it would fail with

```
AttributeError: 'bool' object has no attribute 'any'
```
See #17105 for a code snippet.

Replacing `zeros_like(objarray)` with `zeros()` because the first unnecessarily returns an array of zeros with the same types as `objarray`. We only want the zeros, not the type, to be able to later compare against -1 and get an array as a result:

The result of `zeros_like()` with dates gives a boolean after comparison
```
>>> myarr_fromindex = np.zeros_like(pd.DatetimeIndex([2,3]))
>>> myarr_fromindex
array(['1970-01-01T00:00:00.000000000', '1970-01-01T00:00:00.000000000'],
      dtype='datetime64[ns]')
>>> 
>>> type(myarr_fromindex)
<type 'numpy.ndarray'>
>>>
>>> myarr_fromindex == -1
False
```

The result of `zeros_like()` with numbers gives an array after comparison
```
>>> 
>>> 
>>> myarr_fromarr = np.zeros_like([2,3])
>>> myarr_fromarr
array([0, 0])
>>> type(myarr_fromarr)
<type 'numpy.ndarray'>
>>> myarr_fromarr == -1
array([False, False])
>>> 
```






Labels:
name: Bug
name: Indexing
description: Related to indexing on series/frames, not to indexes themselves

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20939?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@620784f`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/20939/graphs/tree.svg?src=pr&token=eZ4WkYLtcO&width=650&height=150)](https://codecov.io/gh/pandas-dev/pandas/pull/20939?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##             master   #20939   +/-   ##
=========================================
  Coverage          ?   91.81%           
=========================================
  Files             ?      153           
  Lines             ?    49479           
  Branches          ?        0           
=========================================
  Hits              ?    45428           
  Misses            ?     4051           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.2% <100%> (?)` | |
| #single | `41.85% <0%> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/20939?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexing.py](https://codecov.io/gh/pandas-dev/pandas/pull/20939/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhpbmcucHk=) | `93.55% <100%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20939?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20939?src=pr&el=footer). Last update [620784f...cf5ec7d](https://codecov.io/gh/pandas-dev/pandas/pull/20939?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

thanks! added the requested changes, hopefully its better now :)
moved the test around, will merge on green.
thanks @fersarr