Skip to content

ENH: Standardized timeseries accessor names, #9606 #11489

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

Closed
wants to merge 1 commit into from

Conversation

emilydolson
Copy link
Contributor

In accordance with #9606, I added day_of_week and day_of_year accessors to DatetimeIndex, Timestamp, and Period. Since #9606 didn't mention weekofyear, and there's already week as a replacement for that, I didn't add a week_of_year, but I'm happy to.

I updated the tests and docs, but this is my first PR to pandas involving actual code, so let me know if I missed anything.

@jorisvandenbossche
Copy link
Member

For dayofweek/day_of_week we also already have weekday, so this is adding a third alias for that one ..
So I am a bit torn on this one (although I like the fact that we try to standardize the namings)

@jreback
Copy link
Contributor

jreback commented Oct 31, 2015

@jorisvandenbossche I think we should deprecate the original ones in 0.18 anyhow (eg daysinmonth)

dayofyear = _field_accessor('dayofyear', 'doy', "The ordinal day of the year")
day_of_year = dayofyear
quarter = _field_accessor('quarter', 'q', "The quarter of the date")
Copy link
Contributor

Choose a reason for hiding this comment

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

let's switch the impl to the new names (and make the original ones aliases)
that way they are easy to remove

@jorisvandenbossche
Copy link
Member

Maybe we could also remove these from the dir to avoid all the duplicates in tab completion?

@jreback
Copy link
Contributor

jreback commented Oct 31, 2015

there is a test in test_series for dt accessor that needs updating as well

@jreback
Copy link
Contributor

jreback commented Oct 31, 2015

yep @jorisvandenbossche agreed

@jorisvandenbossche
Copy link
Member

I think choosing one prefered name per attribute, and remove all others from the docs (only mentioning them somewhere as being aliases) and tab completion, is maybe a less 'aggresive' way for striving for consistency instead of really deprecating them

@jreback
Copy link
Contributor

jreback commented Oct 31, 2015

sure that's fine too

@jreback
Copy link
Contributor

jreback commented Oct 31, 2015

@emilydolson you will need to define

def _dir_deletions()

which returns a set of the attributes to remove

@jreback jreback added Datetime Datetime data dtype API Design labels Oct 31, 2015
@emilydolson
Copy link
Contributor Author

I've got the tab completion fixed for DatetimeIndex and PeriodIndex, but defining _dir_deletions() in Timestamp doesn't seem to affect the return value of __dir__(). Is there something about Cython that might interfere with _dir_deletions?

@jreback
Copy link
Contributor

jreback commented Nov 5, 2015

so the issue here is that Timestamp needs to inherit from PandasObject, which is in pandas.core.base. But you can't simply include that as it would have a circular dependency.

So here is what we need to do.

Move from pandas.core.base, StringMixin and PandasObject to a new module, call it pandas.core.object. import this to pandas.core.base (you may want to change imports of PandasObject elsewhere in the codebase). Then you can import this as a mix-in for Timestamp (in tslib.pyx).

long-story-short this will then work.

@jreback
Copy link
Contributor

jreback commented Nov 25, 2015

can you rebase / update

also let's deprecate the old names (e.g. w/o the underscores).

You will need to put the warning in the accessor (and probably create a specific function/property for them in order to do this as they are defined by the _field_accessor ATM)

@jreback
Copy link
Contributor

jreback commented Dec 11, 2015

can you update

@jreback
Copy link
Contributor

jreback commented Jan 6, 2016

@emilydolson can you rebase/update according to comments

1 similar comment
@jreback
Copy link
Contributor

jreback commented Jan 20, 2016

@emilydolson can you rebase/update according to comments

@jreback
Copy link
Contributor

jreback commented Jan 30, 2016

closing, but pls reopen if you'd like to update, which would be great.

@jreback jreback closed this Jan 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Datetime Datetime data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants