Skip to content
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

Use parsed date column as index #1251

Closed
changhiskhan opened this issue May 18, 2012 · 5 comments
Closed

Use parsed date column as index #1251

changhiskhan opened this issue May 18, 2012 · 5 comments
Labels
Datetime Datetime data dtype Enhancement IO Data IO issues that don't fit into a more specific label
Milestone

Comments

@changhiskhan
Copy link
Contributor

Right now date conversion is post-processing so the index has already been constructed by then. We need to make it so you can use the newly generated columns as the index

(maybe as simple as a call to set_index)?

@timmie
Copy link
Contributor

timmie commented May 30, 2012

A question regarding usage:
The following works well:

df_in = pa.read_table(sample_file, delimiter=';',
                     date_parser=YMDT,
                     index_col = 'Year_Month_Day_Time', 
                     parse_dates=[[0, 1, 2, 3]])

Why not parse_dates_as_index_col?
The user does not know the future name such as 'Year_Month_Day_Time'....

@changhiskhan
Copy link
Contributor Author

you can do the following without knowing the column name:

df_in = pa.read_table(sample_file, delimiter=';',
date_parser=YMDT,
index_col = 0,
parse_dates=[[0, 1, 2, 3]])

or

df_in = pa.read_table(sample_file, delimiter=';',
date_parser=YMDT,
index_col = 'dt',
parse_dates={'dt' : [0, 1, 2, 3]})

parse_dates_as_index_col would be slightly more convenient. Maybe we can just have it be syntactic sugar that's equivalent to the above.

@timmie
Copy link
Contributor

timmie commented May 30, 2012

Let's add your hint to the docs.

Maybe we can just have it be syntactic sugar that's equivalent to the above.

This would be nice to have in case (mostly actually) there's only one cloumn with dates.

@changhiskhan
Copy link
Contributor Author

Would be very nice to have. Pull requests would be more than welcome :)

@changhiskhan
Copy link
Contributor Author

Here's how you can contribute to the documentation:

http://pandas.pydata.org/developers.html

#1355 #736

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Enhancement IO Data IO issues that don't fit into a more specific label
Projects
None yet
Development

No branches or pull requests

3 participants