-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
@@ -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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
pandas/core/dtypes/dtypes.py
Outdated
@@ -848,7 +848,7 @@ def __setstate__(self, state) -> None: | |||
|
|||
|
|||
@register_extension_dtype | |||
class PeriodDtype(PandasExtensionDtype): | |||
class PeriodDtype(dtypes.PeriodPseudoDtype, PandasExtensionDtype): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
looks good. slightly concerned about the UNDEFINED case (e.g. we don't assert this anywhere)........ |
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 |
This will allow us to start getting rid of
get_freq_code
usages and related libfrequencies functions that are unnecessarily roundabout.