Skip to content

ENH: Add timetz attribute to DatetimeIndex and Timestamp #21358

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
mroeschke opened this issue Jun 7, 2018 · 11 comments · Fixed by #22132
Closed

ENH: Add timetz attribute to DatetimeIndex and Timestamp #21358

mroeschke opened this issue Jun 7, 2018 · 11 comments · Fixed by #22132
Labels
Enhancement Needs Discussion Requires discussion from core team before further action Timezones Timezone data dtype
Milestone

Comments

@mroeschke
Copy link
Member

Currently DatetimeIndex.time returns a numpy array of local datetime.times. In #18461, the resulting datetime.times gained timezone information (but was an undocumented changed) and was subsequently reverted in #21281. Having .time return timezone information would still be a nice enhancement.

If we allow DatetimeIndex.time to return timezone information, timeseries.rst will need to be changed since it currently indicates that .time does not return timezone information.

@mroeschke mroeschke added Enhancement Timezones Timezone data dtype labels Jun 7, 2018
@mroeschke mroeschke added this to the Next Major Release milestone Jun 7, 2018
@jquinon
Copy link
Contributor

jquinon commented Jul 6, 2018

Can I work on this? I'm new to working on pandas, but this seems like a fairly simple issue to get started with.

@mroeschke
Copy link
Member Author

Go for it @jquinon! The main job would be to undo the revision in #21281 make sure this change is documented.

@jreback jreback modified the milestones: Contributions Welcome, 0.24.0 Jul 12, 2018
@jorisvandenbossche jorisvandenbossche removed this from the 0.24.0 milestone Jul 20, 2018
@jorisvandenbossche jorisvandenbossche added the Needs Discussion Requires discussion from core team before further action label Jul 20, 2018
@mroeschke
Copy link
Member Author

So now DatetimeIndex.time matches datetime.time() (minus the property vs method difference) which is an ideal consistency.

However, there is a datetime.timetz() method that returns time with timezone information. We could match the api and have a DatetimeIndex.timetz method, but I am not the biggest fan of the name.

I would prefer instead having DatetimeIndex.time(tz=False) that would match the method-like time api of the standard library, but use a keyword arg to return tz information.

Thoughts?

@jreback
Copy link
Contributor

jreback commented Jul 20, 2018

yeah that would be ok except it’s current a property - not sure we can change this

@mroeschke
Copy link
Member Author

It would be an API change; otherwise, I don't recall an internal reason why we can't break it.

@jorisvandenbossche
Copy link
Member

I am not sure this (adding a tz keyword) is worth the API change. Changing from a attribute to method is a quite big change, as every use of the current attribute would be impacted.

@mroeschke
Copy link
Member Author

Fair enough. Should we then mimic the standard library and add a .timetz property?

@jorisvandenbossche
Copy link
Member

Should we then mimic the standard library and add a .timetz property?

I personally don't really care about adding it, but also won't object if others want it.

@mroeschke mroeschke reopened this Jul 23, 2018
@mroeschke
Copy link
Member Author

@jquinon if you're interested to add a timetz property to DatetimeIndex and Timestamp

@mroeschke mroeschke changed the title ENH: Allow DatetimeIndex.time to return timezone information ENH: Add timetz attribute to DatetimeIndex and Timestamp Jul 23, 2018
@jquinon
Copy link
Contributor

jquinon commented Jul 23, 2018

If everyone is cool with it then sure. @jreback

@jreback
Copy link
Contributor

jreback commented Jul 23, 2018

yep this sounds ok

@jreback jreback added this to the 0.24.0 milestone Aug 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Needs Discussion Requires discussion from core team before further action Timezones Timezone data dtype
Projects
None yet
4 participants