Skip to content

DOC add to_datetime to api.rst #3859

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

Merged
merged 4 commits into from
Jun 21, 2013
Merged

Conversation

hayd
Copy link
Contributor

@hayd hayd commented Jun 12, 2013

Either I'm being thick or to_datetime isn't in the docs (does adding it like this add it?)

Should also put something in basics...?

@jreback
Copy link
Contributor

jreback commented Jun 12, 2013

there should be an example in timeseries.rst and/or basics.rst
but can't remember one

@cpcloud
Copy link
Member

cpcloud commented Jun 12, 2013

should be generated by the API docs. grin shows nothing in those that @jreback just mentioned

@hayd
Copy link
Contributor Author

hayd commented Jun 12, 2013

@jreback http://pandas.pydata.org/pandas-docs/dev/search.html?q=to_datetime&check_keywords=yes&area=default only result is "what's new".

Should one go in basics or timeseries? (I'd vote for basics.)

@jreback
Copy link
Contributor

jreback commented Jun 12, 2013

I would put near the top of timeseries (before time spans)
prob could create a separate section (conversions?)
as several options need to be explained, format, day first, tz,
and a link / mention in basics / dtypes

@hayd
Copy link
Contributor Author

hayd commented Jun 13, 2013

Can I include unit ? :)

@jreback
Copy link
Contributor

jreback commented Jun 13, 2013

yeh...goign to merge that right now in fact......

I think its a reasonable api, yes?

@jreback
Copy link
Contributor

jreback commented Jun 13, 2013

units defined in #3818

@jreback
Copy link
Contributor

jreback commented Jun 13, 2013

@hayd fyi...I believe that format option is currentlly ignored, remember that from somewhere...?

@hayd
Copy link
Contributor Author

hayd commented Jun 13, 2013

I was worried this was going to be a barrel of worms. maybe there is a reason this function isn't documented... :p

@jreback
Copy link
Contributor

jreback commented Jun 13, 2013

is it a barrel?

@hayd
Copy link
Contributor Author

hayd commented Jun 13, 2013

Nah... putting something together now. (sorry, just got flustered with above issue)

@hayd
Copy link
Contributor Author

hayd commented Jun 13, 2013

Also that dayfirst isn't strict. :S

@cpcloud
Copy link
Member

cpcloud commented Jun 16, 2013

@jreback @hayd merge?

@jreback
Copy link
Contributor

jreback commented Jun 16, 2013

I don't think this is ready yet

@cpcloud
Copy link
Member

cpcloud commented Jun 16, 2013

k

@hayd
Copy link
Contributor Author

hayd commented Jun 16, 2013

It could be merged as is, it would at least get to_datetime to the docs.

I've written "something" about using to_datetime in tseries api, but not pushed it yet...

@hayd
Copy link
Contributor Author

hayd commented Jun 18, 2013

I've done a little more on this, feedback welcome...


.. ipython:: python

to_datetime(['2009-07-31', 'asd'])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably could add something about raise here. (Also, I really dislike that this is default behaviour)

Copy link
Member

Choose a reason for hiding this comment

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

do u think that it should convert by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think errors='raise' should be the default...

Copy link
Contributor

Choose a reason for hiding this comment

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

fyi...changing errors='raise' in theory a good idea, but breaks bunch of stuff.....will have to decide on that later...otherwise this looks ready?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just rebased, so will check I'm not saying anything stupid and then merge...

@cpcloud
Copy link
Member

cpcloud commented Jun 18, 2013

pd.to_datetime([1, '2']) is possibly surprising maybe note that?

@cpcloud
Copy link
Member

cpcloud commented Jun 18, 2013

dateutil defaults on making a date string of just an integer midnight on the current day iirc

@hayd
Copy link
Contributor Author

hayd commented Jun 18, 2013

@cpcloud woah! I'd never done: pd.to_datetime(['2']), er!! Will add it in.

@hayd
Copy link
Contributor Author

hayd commented Jun 18, 2013

That is also strange, and the thing which means that to_datetime isn't just map(Timestamp, x), I dislike examples where it isn't (but they need to be included).

@jreback
Copy link
Contributor

jreback commented Jun 18, 2013

this is good!

see #3890, which resolves almost all of the inconsistencies

@hayd
Copy link
Contributor Author

hayd commented Jun 18, 2013

Ah cool! Didn't realise hasn't been merged yet! :)


To convert a Series or list-like object of date-like objects e.g. strings,
epochs, or a mixture, you can use the ``to_datetime`` function. When passed
a Series, this returns a Series (with the same index), whilst a list-like
Copy link
Contributor

Choose a reason for hiding this comment

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

whilst -> while?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@hayd
Copy link
Contributor Author

hayd commented Jun 19, 2013

This is still whacky:

@hayd
Copy link
Contributor Author

hayd commented Jun 19, 2013

In [4]: pd.to_datetime([1, '1'])
Out[4]:
<class 'pandas.tseries.index.DatetimeIndex'>
[1970-01-01 00:00:00.000000001, 2013-06-01 00:00:00]
Length: 2, Freq: None, Timezone: None

so will mention it

@cpcloud
Copy link
Member

cpcloud commented Jun 19, 2013

not sure there's any other way to go about it. need to use ints for representation but want to be able to parse semi human readable dates and ints...dateutil is extremely lenient except e.g., it won't parse an int. hopefully no one is abusing pandas in this way

@jreback
Copy link
Contributor

jreback commented Jun 19, 2013

can u add that last to #3944?

I think we are all agreed that the default to_ datetime should be more strict

@cpcloud
Copy link
Member

cpcloud commented Jun 19, 2013

done

@jreback
Copy link
Contributor

jreback commented Jun 19, 2013

that why I separated out #3944

dateutil lets everything thru

so have to do some most common case parsing first

need to expand c date parser then can pretty much drop need for dateutil except as fallback

@hayd
Copy link
Contributor Author

hayd commented Jun 19, 2013

(and it's not strict for dayfirst grrr!)

@hayd
Copy link
Contributor Author

hayd commented Jun 19, 2013

Quick once over of this?

@jreback
Copy link
Contributor

jreback commented Jun 19, 2013

looks good

Converting to Timestamps
------------------------

To convert a Series or list-like object of date-like objects e.g. strings,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

a lot of likes and objects here, but I think it'll do

@jreback
Copy link
Contributor

jreback commented Jun 20, 2013

mergable?

@hayd
Copy link
Contributor Author

hayd commented Jun 21, 2013

I'm still meh on the first line, but I think it's fine.

hayd added a commit that referenced this pull request Jun 21, 2013
@hayd hayd merged commit f5a2b35 into pandas-dev:master Jun 21, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants