-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
datetools.parse interface #5886
Comments
I you already have integer day,month, year just do this, and make sure that you specify format '%Y%m%d'; its specially optimized
Parsing the actual string
|
A couple of comments. This is not completely obvious. I'll see about adding this and similar examples to the docstring. In general, more examples in docstrings with common patterns would be welcome.
It'd be nice to have a function that handles this and dates handled by dateutil.parse. And this returns an array for some reason, which I find to be odd. I see the box keyword, but since your example returns a Series, not a DatetimeIndex as indicated, wouldn't it make sense for everything just to return a Series? Shouldn't |
not sure where the name came from. I agree creating a date from columns is not so obvious (a little more obvious if you are reading it in with would appreciate the combing example that as a docstring / doc example / cookbook - I thought about how to make it 'automatically' do it but don't want to change the API...if you think of someway great! (could have a convenience function, but not big on that) These will return a Series if you pass a Series/array. The boxing is internally used by the DatetimeIndex parser (which just calls this); you can use it if you want an Index instead. It also returns a scalar Timestamp if only 1 value is passed as a scalar. I could see the I don't think can change |
Also maybe import parse from dateutils as _parse to discourage its use. I had no idea it wasn't really intended to be part of the public API. |
I think the import is a big 'confused' as its in several places (some as |
ok...i'll create a todo list at the top of this PR then |
My example would be parsed like
Though apparently 1980m12 is recognized as minute not month. I'd have Not unheard of formats commonly handled by econometric/statistical software.
|
I don't much care if I get Periods or TimeStamps, etc. As far as I'm concerned (as a user) they're pretty much the same. As a developer, I've written most software to be agnostic about what it gets as long as it can infer a frequency. |
mentioned in SO |
@jreback : Is this issue even relevant anymore? IINM, |
look at the imports they are * so yes |
@jreback : I don't understand what you mean by that. |
do a dir() on the namespace |
Again, do not follow. Just try the following: >>> import pandas as pd
>>> pd.datetools.parse
...
AttributeError: module 'pandas.core.datetools' has no attribute 'parse' |
dir() |
Again, do not follow. Just try the following: >>> import pandas as pd
>>> 'parse' in dir(pd)
False
>>> 'parse' in dir(pd.datetools)
False I'm really not understanding what you're saying here. |
I guess it's gone all of these issues are either fixed then or elsewhere (to_period needs a standalone issue) |
|
no it's like to_datetime but creates PeriodIndexes |
Got it, done: #14108 |
_parse/parse
from dateutilsto_period
to createPeriodIndex
I started to make a PR #5885 to fix what I thought was a typo before realizing that this was intentional. It still doesn't make much sense to me though why I would want this return of datetime, _result, resolution. Maybe the whole approach could use a refactor. Otherwise what am I missing?
My typical use case for datetools.parse is something like
dates = map(lambda x : parse(' '.join(x)), zip(df.day, df.month, df.year))
A couple of questions.
pd.parse_dates
that is a general parser for both strings and works on array-like input, deprecating datetools.parse, datetools.parse_time_string, and datetools.to_datetime. This function could also have a flag to return Period or TimeStamp objects with frequency information instead of the current return of the parsed object and resolution. Given that I'm having to do things likedates = [x[0] for x in map(lambda x : parse(' '.join(x)), zip(df.day, df.month, df.year))]
Thoughts?
The text was updated successfully, but these errors were encountered: