Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: DatetimeIndex slicing with boolean Index raises TypeError #22852

Merged
merged 2 commits into from
Nov 7, 2018

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented Sep 27, 2018

@pep8speaks
Copy link

pep8speaks commented Sep 27, 2018

Hello @sinhrks! Thanks for updating the PR.

Comment last updated on September 27, 2018 at 09:07 Hours UTC

@sinhrks sinhrks added Bug Indexing Related to indexing on series/frames, not to indexes themselves labels Sep 27, 2018
@codecov
Copy link

codecov bot commented Sep 27, 2018

Codecov Report

Merging #22852 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #22852   +/-   ##
=======================================
  Coverage   92.25%   92.25%           
=======================================
  Files         161      161           
  Lines       51207    51207           
=======================================
  Hits        47239    47239           
  Misses       3968     3968
Flag Coverage Δ
#multiple 90.63% <100%> (ø) ⬆️
#single 42.28% <100%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/arrays/datetimelike.py 96.16% <100%> (ø) ⬆️
pandas/core/indexes/multi.py 95.46% <100%> (ø) ⬆️
pandas/core/indexes/base.py 96.45% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 528527b...420e5c4. Read the comment docs.

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good could just use parametrization to make test cases cleaner


def test_getitem_bool_index(self):
# GH#22533
idx1 = pd.date_range('2011-01-01', '2011-01-05', freq='D', name='idx')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than listing these out sequentially can you parametrize the various cases? Would make the code more succinct and readable

@sinhrks sinhrks force-pushed the gh22533 branch 2 times, most recently from 2e4d406 to dbf2971 Compare September 28, 2018 05:52
@@ -843,6 +843,28 @@ def test_join_outer(self):
tm.assert_numpy_array_equal(lidx, elidx)
tm.assert_numpy_array_equal(ridx, eridx)

@pytest.mark.parametrize('ind1', [[True] * 5, pd.Index([True] * 5)])
@pytest.mark.parametrize('ind2', [[True, False, True, False, False],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you just add these all to TestIndexOps to get overage on all index (and series) for this. Note that there is an open issue to fixture this ;<

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, added some tests to TestIndexOps.

@sinhrks sinhrks force-pushed the gh22533 branch 3 times, most recently from 6ba6dd8 to cbd9184 Compare October 31, 2018 00:54
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. just want to avoid duplicating some tests if easy & possible. ping on green.

pandas/tests/test_base.py Show resolved Hide resolved
@jreback jreback added this to the 0.24.0 milestone Oct 31, 2018
@jreback
Copy link
Contributor

jreback commented Nov 1, 2018

lgtm. ping on green. @WillAyd over to you.

@jreback
Copy link
Contributor

jreback commented Nov 6, 2018

can you merge master and ping on green.

@jreback jreback merged commit 1e23524 into pandas-dev:master Nov 7, 2018
@jreback
Copy link
Contributor

jreback commented Nov 7, 2018

thanks @sinhrks

@sinhrks sinhrks deleted the gh22533 branch November 8, 2018 02:08
thoo added a commit to thoo/pandas that referenced this pull request Nov 10, 2018
…fixed

* upstream/master: (47 commits)
  CLN: remove values attribute from datetimelike EAs (pandas-dev#23603)
  DOC/CI: Add linting to rst files, and fix issues (pandas-dev#23381)
  PERF: Speeds up creation of Period, PeriodArray, with Offset freq (pandas-dev#23589)
  PERF: define is_all_dates to shortcut inadvertent copy when slicing an IntervalIndex (pandas-dev#23591)
  TST: Tests and Helpers for Datetime/Period Arrays (pandas-dev#23502)
  Update description of Index._values/values/ndarray_values (pandas-dev#23507)
  Fixes to make validate_docstrings.py not generate warnings or unwanted output (pandas-dev#23552)
  DOC: Added note about groupby excluding Decimal columns by default (pandas-dev#18953)
  ENH: Support writing timestamps with timezones with to_sql (pandas-dev#22654)
  CI: Auto-cancel redundant builds (pandas-dev#23523)
  Preserve EA dtype in DataFrame.stack (pandas-dev#23285)
  TST: Fix dtype mismatch on 32bit in IntervalTree get_indexer test (pandas-dev#23468)
  BUG: raise if invalid freq is passed (pandas-dev#23546)
  remove uses of (ts)?lib.(NaT|iNaT|Timestamp) (pandas-dev#23562)
  BUG: Fix error message for invalid HTML flavor (pandas-dev#23550)
  ENH: Support EAs in Series.unstack (pandas-dev#23284)
  DOC: Updating DataFrame.join docstring (pandas-dev#23471)
  TST: coverage for skipped tests in io/formats/test_to_html.py (pandas-dev#22888)
  BUG: Return KeyError for invalid string key (pandas-dev#23540)
  BUG: DatetimeIndex slicing with boolean Index raises TypeError (pandas-dev#22852)
  ...
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: DatetimeIndex.__getitem__ with boolean Index mask with False raises TypeError
4 participants