Skip to content

Instantly share code, notes, and snippets.

@ahmedshahriar
Created February 15, 2021 20:19
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 ahmedshahriar/3caa7389304acd5f2e756abb0ccb7be4 to your computer and use it in GitHub Desktop.
Save ahmedshahriar/3caa7389304acd5f2e756abb0ccb7be4 to your computer and use it in GitHub Desktop.
import pandas as pd
# using pandas datetime converter
df = pd.DataFrame(pd.Series(['2021-02-04T09:15:00+05:30', '2021-02-04T09:15:00+05:30', '2021-02-04T09:15:00+05:30']))
pd.to_datetime(df[0]).dt.date
pd.to_datetime(df[0]).dt.time
# using dateutil library
from dateutil.parser import parse
df[0].map(lambda x: parse(x).date())
df[0].map(lambda x: parse(x).time())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment