Skip to content

Commit

Permalink
fix BUG: ValueError when performing rolling covariance on multi index…
Browse files Browse the repository at this point in the history
…ed DataFrame (#16814)

* fix multi index names

* fix line length to pep8

* added what's new entry and reference issue number in test

* Update test_multi.py

* Update v0.20.3.txt
  • Loading branch information
Tuan authored and ri938 committed Jul 7, 2017
1 parent 800b40d commit 5362447
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.20.3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Bug Fixes
- Fixed compat with loading a ``DataFrame`` with a ``PeriodIndex``, from a ``format='fixed'`` HDFStore, in Python 3, that was written in Python 2 (:issue:`16781`)
- Fixed a pytest marker failing downstream packages' tests suites (:issue:`16680`)
- Bug in reindexing on an empty ``CategoricalIndex`` (:issue:`16770`)
- Fixed bug where computing the rolling covariance of a MultiIndexed ``DataFrame`` improperly raised a ``ValueError`` (:issue:`16789`)

Conversion
^^^^^^^^^^
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/indexes/test_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ def f():

tm.assert_raises_regex(ValueError, 'The truth value of a', f)

def test_multi_index_names(self):

# GH 16789
cols = pd.MultiIndex.from_product([['A', 'B'], ['C', 'D', 'E']],
names=['1', '2'])
df = pd.DataFrame(np.ones((10, 6)), columns=cols)
rolling_result = df.rolling(3).cov()
assert rolling_result.index.names == [None, '1', '2']

def test_labels_dtypes(self):

# GH 8456
Expand Down

0 comments on commit 5362447

Please sign in to comment.