Skip to content

REF: mix PeriodPseudoDtype into PeriodDtype #34590

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 5 commits into from
Jun 8, 2020

Conversation

jbrockmendel
Copy link
Member

This will allow us to start getting rid of get_freq_code usages and related libfrequencies functions that are unnecessarily roundabout.

@@ -896,7 +896,8 @@ def __new__(cls, freq=None):

elif freq is None:
# empty constructor for pickle compat
u = object.__new__(cls)
# -10_000 corresponds to PeriodDtypeCode.UNDEFINED
Copy link
Contributor

Choose a reason for hiding this comment

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

is this actually hit in tests? what is the point of UNDEFINED? I mean, when does this become defined

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. We have a test that constructs PeriodDtype() which goes through this path. the existing comment a couple lines up suggests this is for pickle compat

Copy link
Contributor

Choose a reason for hiding this comment

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

right, how does this get resolved though? do you see periods with undefined after 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.

i think the idea is to use it as a placeholder until you can get a "real" PeriodDtype. e.g. if you know that you are parsing a csv column to Period but dont yet know the freq. just speculating here

@@ -848,7 +848,7 @@ def __setstate__(self, state) -> None:


@register_extension_dtype
class PeriodDtype(PandasExtensionDtype):
class PeriodDtype(dtypes.PeriodPseudoDtype, PandasExtensionDtype):
Copy link
Contributor

Choose a reason for hiding this comment

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

not a huge fan of PeriodPseuodDtype name

Copy link
Member Author

Choose a reason for hiding this comment

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

im open to suggestions. joris objected to calling it PeriodDtype

Copy link
Contributor

Choose a reason for hiding this comment

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

this is basically a cython PeriodBaseDtype

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated with new name + green

@jreback jreback added the Period Period data type label Jun 8, 2020
@jreback jreback added this to the 1.1 milestone Jun 8, 2020
@jreback jreback merged commit 91241ae into pandas-dev:master Jun 8, 2020
@jreback
Copy link
Contributor

jreback commented Jun 8, 2020

looks good. slightly concerned about the UNDEFINED case (e.g. we don't assert this anywhere)........

@jbrockmendel
Copy link
Member Author

slightly concerned about the UNDEFINED case

It also shows up in period.pyx as FR_UND (xref #34588), so i dont think we'll be able to get rid of it, but we should at least be able to get to a point with fewer of these enum-like codes lying around

@jbrockmendel jbrockmendel deleted the ref-period-dtype-core branch June 8, 2020 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Period Period data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants