how to format 09-jun-2019 00:00:00 in pandas format in python

To format the date "09-jun-2019 00:00:00" in pandas format in Python, you can use the strftime function from the datetime module to convert the string to a pandas datetime object. Here's how you can do it:

main.py
import pandas as pd
from datetime import datetime

date_str = "09-jun-2019 00:00:00"
date_obj = datetime.strptime(date_str, "%d-%b-%Y %H:%M:%S")

formatted_date = pd.to_datetime(date_obj)
188 chars
8 lines

Now, formatted_date will hold the pandas datetime object which can be further manipulated or used in pandas operations.

related categories

gistlibby LogSnag