alteryx / woodwork

Woodwork is a Python library that provides robust methods for managing and communicating data typing information.
https://woodwork.alteryx.com
BSD 3-Clause "New" or "Revised" License
142 stars 20 forks source link

Support selecting by instantiated Logical Type #234

Open gsheni opened 3 years ago

gsheni commented 3 years ago
ymd_format = Datetime(datetime_format='%Y~%m~%d')

df = pd.DataFrame({
    'dates': ["2019/01/01", "2019/01/02", "2019/01/03"],
    'ymd': ["2019~01~01", "2019~01~02", "2019~01~03"],
})
dt = DataTable(df,
               logical_types={'ymd': ymd_format,
                              'dates': Datetime})
dt.select(ymd_format)
thehomebrewnerd commented 3 years ago

With the accessor approach the code should be:

ymd_format = Datetime(datetime_format='%Y~%m~%d')

df = pd.DataFrame({
    'dates': ["2019/01/01", "2019/01/02", "2019/01/03"],
    'ymd': ["2019~01~01", "2019~01~02", "2019~01~03"],
})
df.ww.init(logical_types={'ymd': ymd_format, 'dates': Datetime})
df.ww.select(ymd_format)