-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
_offset_map appears to have redundant data #5028
Comments
I was able to verify that ALL entries in def test_offset_map(self):
for name,offset in pandas.tseries.frequencies._offset_map.iteritems():
assert name == None if offset is None else offset.rule_code Given that is there any reason to keep the code looking like this: _offset_map = {
'D': Day(),
'C': cday,
'B': BDay(),
'H': Hour(),
'T': Minute(),
'S': Second(),
'L': Milli(),
'U': Micro(),
... |
Instead of |
@cpcloud I actually think you are wrong there :-) |
On second look, my precedence is wrong. |
The
|
@cancan101 Not a big deal. You can also use a plain ol' |
That is what happens when you write the code initially without any if/else and then realize there are |
Also now that the test is fixed, it DOES fail... Looking into that. |
Okay. So it looks like that test will fail with
Any reason not to just put the 'QS' et. al. entries into the As a side note: This code is not well defined for the above situations: _offset_names = {}
for name, offset in compat.iteritems(_offset_map):
if offset is None:
continue
offset.name = name
_offset_names[offset] = name |
#5148 is my WIP for this. So far the above unit test passes and the values in |
Looks like |
Many / most of the entries in
_offset_map
look like:where
X
is a string literal for what would have been returned byOffsetX().rule_code
See for example: https://github.com/pydata/pandas/blob/master/pandas/tseries/frequencies.py#L132
This makes adding to and maintaining the list of Offsets more cumbersome.
Manually populating
_offset_map
could be reserved for cases in which the entry in_offset_map
is not the same as therule_code
. The remaining cases would be auto-populated using aclassmethod
on the Offset to return all possible Offsets.A related map is
_offset_names
One suggestion would be to change
get_offset_name
to returnoffset.rule_code
in the else case rather than raising an exception. This would remove the need for_offset_names
The text was updated successfully, but these errors were encountered: