{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/9412","labels_url":"https://api.github.com/repos/pydata/pandas/issues/9412/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/9412/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/9412/events","html_url":"https://github.com/pydata/pandas/issues/9412","id":56554767,"number":9412,"title":"Vectorizing pandas Date Functions","user":{"login":"aschneiderman","id":6363322,"avatar_url":"https://avatars.githubusercontent.com/u/6363322?v=3","gravatar_id":"","url":"https://api.github.com/users/aschneiderman","html_url":"https://github.com/aschneiderman","followers_url":"https://api.github.com/users/aschneiderman/followers","following_url":"https://api.github.com/users/aschneiderman/following{/other_user}","gists_url":"https://api.github.com/users/aschneiderman/gists{/gist_id}","starred_url":"https://api.github.com/users/aschneiderman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aschneiderman/subscriptions","organizations_url":"https://api.github.com/users/aschneiderman/orgs","repos_url":"https://api.github.com/users/aschneiderman/repos","events_url":"https://api.github.com/users/aschneiderman/events{/privacy}","received_events_url":"https://api.github.com/users/aschneiderman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-04T16:58:14Z","updated_at":"2015-02-04T17:02:24Z","closed_at":null,"body":"pandas has great methods for manipulating index dates, which works well for timeseries data. But for other kinds of data, to manipulate a date column you have to use lambda (or set that column to be the index).  For example, a lot of the beginners I'm training work with transactional data that looks something like this:\r\n\r\n```python\r\npurchases = pd.DataFrame({\r\n'Purchase_Date': ['9/9/2013', '9/9/2013', '9/10/2013', '9/28/2013', '10/6/2013', '10/7/2013',\r\n'10/18/2013', '10/18/2013', '11/1/2013'],\r\n'Delivery_Date': ['9/11/2013', '9/11/2013', '9/18/2013', '10/2/2013', '10/8/2013', '10/8/2013', '10/22/2013', '10/22/2013', '11/8/2013'],\r\n'Size': ['Medium', 'Small', 'Large', 'Small', 'Medium', 'Small', 'Large', 'Medium', 'Small'],\r\n'Color': ['Red', 'Blue', 'Green', 'Red', 'Red', 'Green', 'Purple', 'Purple', 'Black']})\r\n```\r\nHere's what you have to do now to get the delivery purchase month:\r\n```python\r\npurchases[\"Delivery_Month\"] = purchases[\"Delivery_Date\"].apply(lambda x: pd.to_Datetime(x).month)\r\n```\r\nFor beginners who don't have a science or programming background, using apply and lambda is pretty confusing. And since one of the first things these beginners want to do is analyze their data by dates, it's a potential stumbling block to their adopting pandas.\r\n\r\nIt would be great if date functions could be vectorized the way strings have so that for example you could instead write:\r\n```python\r\npurchases[\"Delivery_Month\"] = purchases[\"Delivery_Date\"].month\r\n```\r\nI think this change might help make pandas more accessible to a wider audience. For example, as part of [Data Chefs](http://datachefs.org), I'm working with a group of folks to create an online course and cookbook on slicing & dicing data with pandas. Having vectorized date functions would remove a small but important barrier to our target audience becoming comfortable using pandas."},"comment":{"url":"https://api.github.com/repos/pydata/pandas/issues/comments/72893538","html_url":"https://github.com/pydata/pandas/issues/9412#issuecomment-72893538","issue_url":"https://api.github.com/repos/pydata/pandas/issues/9412","id":72893538,"user":{"login":"jreback","id":953992,"avatar_url":"https://avatars.githubusercontent.com/u/953992?v=3","gravatar_id":"","url":"https://api.github.com/users/jreback","html_url":"https://github.com/jreback","followers_url":"https://api.github.com/users/jreback/followers","following_url":"https://api.github.com/users/jreback/following{/other_user}","gists_url":"https://api.github.com/users/jreback/gists{/gist_id}","starred_url":"https://api.github.com/users/jreback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jreback/subscriptions","organizations_url":"https://api.github.com/users/jreback/orgs","repos_url":"https://api.github.com/users/jreback/repos","events_url":"https://api.github.com/users/jreback/events{/privacy}","received_events_url":"https://api.github.com/users/jreback/received_events","type":"User","site_admin":false},"created_at":"2015-02-04T17:02:24Z","updated_at":"2015-02-04T17:02:24Z","body":"you mean like this? http://pandas.pydata.org/pandas-docs/version/0.15.1/basics.html#basics-dt-accessors"}}