Skip to content

Instantly share code, notes, and snippets.

@grigory93
Last active July 20, 2021 03:56
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 grigory93/064f2a7183a2987893dce398a013d980 to your computer and use it in GitHub Desktop.
Save grigory93/064f2a7183a2987893dce398a013d980 to your computer and use it in GitHub Desktop.
from datetime import date
import datatable as dt
dt.Frame([dt.Type.date32.min, date(2021, 7, 20), dt.Type.date32.max], stype='date32')
DT = dt.Frame([1, 1000, 100000], stype='date32')
DT
DT = dt.Frame({"Date": ["2021-05-24", "2021-05-26", "2021-05-27"]}, stype='date32')
DT
DT = dt.Frame({"Date": ["2021-05-24", "2021-05-26", "2021-05-27"]})
DT[0] = dt.Type.date32
DT
DT = dt.Frame({"Date": ["05/24/2021", "05/26/2021", "05/27/2021"]}, stype='date32')
DT
DT = dt.Frame({"Date": ["05/24/2021", "05/26/2021", "05/27/2021"]})
DT[:, dt.update(Date =
dt.time.ymd(dt.as_type(dt.str.slice(dt.f.Date, 6, 10), int),
dt.as_type(dt.str.slice(dt.f.Date, 0, 2), int),
dt.as_type(dt.str.slice(dt.f.Date, 3, 5), int)))]
DT
from datetime import datetime
dt.Frame([dt.Type.time64.min, datetime(2021, 7, 20, 1, 32, 52, 125555), dt.Type.time64.max])
DT = dt.Frame(Time = ["2018-01-31 03:16:57", "2021-06-15 15:44:23.951", "1965-11-25 19:29:00"])
DT[0] = dt.Type.time64
DT
from datatable import f
DT = dt.Frame(Y=[2001, 2003, 2005, 2020, 1960],
M=[1, 5, 4, 11, 8],
D=[12, 18, 30, 1, 14],
h=[7, 14, 22, 23, 12],
m=[15, 30, 0, 59, 0],
s=[12, 23, 0, 59, 27],
ns=[0, 0, 0, 999999000, 123000])
DT[:, dt.update(Time = dt.time.ymdt(f.Y, f.M, f.D, f.h, f.m, f.s, f.ns))]
DT
DT[dt.time.year(f.Time) < 2000, :]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment