Skip to content

Instantly share code, notes, and snippets.

@bhishanpdl
Last active September 3, 2018 20:20
Show Gist options
  • Save bhishanpdl/4d69b4c62e8f0c91fb4c9dfd477b60b0 to your computer and use it in GitHub Desktop.
Save bhishanpdl/4d69b4c62e8f0c91fb4c9dfd477b60b0 to your computer and use it in GitHub Desktop.
import pandas as pd
import calendar
# Ref: https://docs.python.org/2/library/datetime.html
df['release_year'] = pd.to_datetime(df['release_date'], format='%m/%d/%y')
df['release_month'] = df['release_year'].dt.month
df['month_name'] = df['release_month'].apply(lambda x: calendar.month_abbr[x])
# 2018-02-28 21:03:37
df[''] = pd.to_datetime(df[''], format='%Y-%m-%d %H:%M:%S')
df.dtypes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment