Skip to content

implementation of from_julian_date() #11276

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
sebhahn opened this issue Oct 9, 2015 · 9 comments
Closed

implementation of from_julian_date() #11276

sebhahn opened this issue Oct 9, 2015 · 9 comments
Labels
Datetime Datetime data dtype Enhancement
Milestone

Comments

@sebhahn
Copy link

sebhahn commented Oct 9, 2015

pandas.DatetimeIndex supports a method called to_julian_date() would it be easily possible to support a function/method doing the opposite, i.e. from_julian_date()?

@chris-b1
Copy link
Contributor

chris-b1 commented Oct 9, 2015

fyi, this is somewhat easy to do with the current to_datetime, just subtract the offset and specify that the unit is days.

In [66]: julian_dates = pd.date_range('2014-1-1', periods=10).to_julian_date().values

In [67]: julian_dates
Out[67]: 
array([ 2456658.5,  2456659.5,  2456660.5,  2456661.5,  2456662.5,
        2456663.5,  2456664.5,  2456665.5,  2456666.5,  2456667.5])

In [68]: pd.to_datetime(julian_dates - pd.Timestamp(0).to_julian_date(), unit='D')
Out[68]: 
DatetimeIndex(['2014-01-01', '2014-01-02', '2014-01-03', '2014-01-04',
               '2014-01-05', '2014-01-06', '2014-01-07', '2014-01-08',
               '2014-01-09', '2014-01-10'],
              dtype='datetime64[ns]', freq=None)

@sebhahn
Copy link
Author

sebhahn commented Oct 9, 2015

interesting solution, thank you very much for that!

@jreback jreback added Enhancement Datetime Datetime data dtype labels Oct 9, 2015
@jreback
Copy link
Contributor

jreback commented Oct 9, 2015

I think this would not be unreasonable to have pd.to_datetime(....., ,unit='julian')
I guess as long as making things up DatetimeIndex.astype('datetime64[julian]') prob a bit much

We don't have any from_* for this kind of thing

@sebhahn
Copy link
Author

sebhahn commented Oct 12, 2015

Good idea! So you plan to support this in the future?

@jreback
Copy link
Contributor

jreback commented Oct 12, 2015

@sebhahn if you'd like to do a PR with the unit='julian' I think would be reasonable to start.

@sumitbinnani
Copy link

@jreback @sebhahn
Is this enhancement being included, and is someone working on the same? If not, I would like to give it a try :-)

@sebhahn
Copy link
Author

sebhahn commented Oct 13, 2015

@sumitbinnani I haven't started yet, so feel free to implement it 😄

@sumitbinnani
Copy link

@sebhahn: Thanks. Will soon submit a patch :-)

@jreback jreback added this to the Someday milestone Oct 16, 2015
sumitbinnani added a commit to sumitbinnani/pandas that referenced this issue Oct 29, 2015
@jreback jreback modified the milestones: 0.18.0, Someday Dec 13, 2015
@jreback jreback modified the milestones: Next Major Release, 0.18.0 Feb 2, 2016
sumitbinnani added a commit to sumitbinnani/pandas that referenced this issue Mar 23, 2016
@jreback jreback modified the milestones: 0.18.1, Next Major Release Apr 20, 2016
@jreback jreback modified the milestones: 0.18.2, 0.18.1 May 1, 2016
jreback pushed a commit to jreback/pandas that referenced this issue May 1, 2016
@jreback jreback modified the milestones: 0.18.1, 0.18.2 May 1, 2016
@jreback jreback modified the milestones: Next Major Release, 0.18.2 Jul 6, 2016
@jreback jreback modified the milestones: 0.20.0, Next Major Release Mar 28, 2017
@jreback jreback closed this as completed in cd24fa9 Apr 2, 2017
@sebhahn
Copy link
Author

sebhahn commented Apr 3, 2017

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants