Created
August 7, 2014 09:10
-
-
Save mickaellegal/6a7824452275db584a00 to your computer and use it in GitHub Desktop.
Python: Cleaning dates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numby as np | |
# import your csv file into a pandas dataframe | |
df = pd.DataFrame('YOUR_FILE.csv') | |
# convert the column with the date to a date format | |
date = pd.to_datetime(df.date_column) | |
# Change the format of the date | |
dates_clean = pd.DataFrame(date.map(lambda x: x.strftime('%Y-%m-%d'))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment