Python - How To Sort Date String In A Data Frame?
I have a df pandas.core.series.Series such that:
0 11/8/16 1 11/8/16 2 6/12/16 3 10/11/15 4 10/11/15 ... 9989 1/21/14 9990 2/26/17 9991 2/26/17 9992 2/26/17 9993 12/30/17
If I use
max() on it, it shows the latest date as '9/9/17', instead of the actual maximum which is, in this case '12/30/17'.
I understand why it is happens - because 9 > 1.
How can I fix it?
Convert the dates to timestamps first:
import pandas as pd df["date"] = pd.to_datetime(df["date"], format="%m/%d/%y") >>> df["date"].max()
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module