Skip to content

Instantly share code, notes, and snippets.

@dyerrington
Created April 21, 2016 04:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dyerrington/3b64ba0660340b6329d789e679db3268 to your computer and use it in GitHub Desktop.
Save dyerrington/3b64ba0660340b6329d789e679db3268 to your computer and use it in GitHub Desktop.
data = [
["2001-10-1", 2, 3, 4],
["2001-11-1", 2, 3, 4],
["2001-05-1", 2, 3, 4],
["2001-05-1", 2, 3, 4],
["2001-03-1", 2, 3, 4]
]
df = pd.DataFrame(data, columns=["date", "a", "b", "c"])
df["my_date"] = pd.to_datetime(df["date"])
df.dtypes
# Mapping specific date series to new features
# df["my_month"] = df["my_date"].map(lambda date: date.month)
# You can also do this for .year, .week, .day for date objects in series
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment