Reputation: 247
I have a dataframe-
df1
Out[12]:
DateTime ClaimStatus NumberOfClaims
0 8/12/2016 Queued 5301
1 8/13/2016 Queued 5419
2 8/14/2016 Queued 5369
3 8/15/2016 Queued 5015
4 8/16/2016 Queued 5081
I want to make the DateTime column format into YYY-MM-DD I know how to make it individually -
from datetime import datetime
date = datetime.strptime("1/4/2014", "%m/%d/%Y")
datetime.strftime(date, "%Y-%m-%d")
How do I apply this to the DateTime column in df1?
Upvotes: 0
Views: 218
Reputation: 23237
You can use the following if you want to keep the column as datetime format:
df1['DateTime'] = pd.to_datetime(df1['DateTime'], format="%m/%d/%Y")
Upvotes: 1