Skip to content

TST: loc misbehaves when Period is at start of 3-level MultiIndex #28628

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

Merged
merged 1 commit into from
Oct 30, 2019

Conversation

proost
Copy link
Contributor

@proost proost commented Sep 26, 2019

If index is MultiIndex and level of 0 is PeriodIndex, loc function raise
exception if all input of loc does not match index values

Background: This bug only happens when MultiIndex's level is 3 and first level index is PeriodIndex. In this situation, if someone access one row using a '.loc' with a miss match key, then would not raise exception.

Someone already change what i try to do parse_time_string function in '_libs.tslibs.parsing'.
in the past,

def parse_time_string(arg, freq=None, dayfirst=None, yearfirst=None):
    if not isinstance(arg, str):
        return arg

What i try to do:

def parse_time_string(arg, freq=None, dayfirst=None, yearfirst=None):
    if not isinstance(arg, str):
        raise TypeError

now in master:

def parse_time_string(arg, freq=None, dayfirst=None, yearfirst=None):
    if not isinstance(arg, str):
        raise TypeError("parse_time_string argument must be str")

Just add tests for issue.

@jbrockmendel
Copy link
Member

Can you add tests specific to parse_time_string. That would go in tests.tslibs.test_parsing

@minhoryang
Copy link

@jbrockmendel ping?

@proost proost force-pushed the period-multiindex branch 3 times, most recently from d54dc74 to afd6897 Compare October 10, 2019 04:05
@proost proost requested a review from jreback October 10, 2019 17:14
@jreback jreback added Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex Period Period data type labels Oct 11, 2019
@jreback
Copy link
Contributor

jreback commented Oct 11, 2019

can you also make sure we have tests for the entire example in the OP (IOW the working cases as well)

@proost
Copy link
Contributor Author

proost commented Oct 17, 2019

@jreback could you also check #29038 ?

@proost proost requested a review from jreback October 17, 2019 01:39
@proost proost force-pushed the period-multiindex branch 6 times, most recently from c1e1e64 to e67736d Compare October 24, 2019 08:48
@proost proost changed the title BUG: loc misbehaves when Period is at start of 3-level MultiIndex TST: loc misbehaves when Period is at start of 3-level MultiIndex Oct 24, 2019
@proost proost force-pushed the period-multiindex branch 3 times, most recently from 23783bf to f08aafe Compare October 25, 2019 01:55
@proost proost requested a review from jreback October 25, 2019 02:56
@jreback jreback added this to the 1.0 milestone Oct 25, 2019
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.

ok looks fine, if you'd remove the note, otherwise lgtm. ping on green.

@proost proost force-pushed the period-multiindex branch 2 times, most recently from 6670997 to 7a70de9 Compare October 26, 2019 02:31
@jreback jreback merged commit ee64ebc into pandas-dev:master Oct 30, 2019
@jreback
Copy link
Contributor

jreback commented Oct 30, 2019

thanks @proost

@proost proost deleted the period-multiindex branch October 30, 2019 14:03
@proost
Copy link
Contributor Author

proost commented Oct 30, 2019

@jbrockmendel @jreback
Thank you for your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex Period Period data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants