Stream: helpdesk (published)

Topic: Case/When Logic with Time Ranges


view this post on Zulip qu bit (Mar 08 2021 at 21:23):

Good Day Coders:

My dataframe:

Instrument = "Piano","Guitar","Harmonica", "Violin"
TIME = Time(00,01,00):Dates.Minute(5):Time(02,00,00)

    Wall_E = DataFrame(ID = 1:10, Temp = rand(15:0.01:40,10),
                   Instrument = rand(Instrument, 10),
                   SessionTimes = rand(TIME,10))

Is there a way I could group SessionTimes into predefined
buckets/intervals (I.E. '0 to 30 minutes', '31 to 60 minutes',
'1 hour or more' (OR 61 minutes or more))?

I am experimenting with Case/When logic for Julia using:

Z = Wall_E[!, 4]
    (Z -> Z = Time(00,00,00):Dates.Minute(5):Time(00,30,00) ? "0 to 30 mins" :
          Z = Time(00,31,00):Dates.Minute(5):Time(01,00,00) ? "31 to 60 minutes" :
          Z > Time(01,00,00) ? "More than 1 hour" :
          Time(Z)).(Z)

But keep returning the following:

TypeError: non-boolean (StepRange{Dates.Time,Dates.Minute}) used in boolean context

I am currently testing binning options using
CategoricalArrays.jl

@Bogumił Kamiński
@Alex Arslan
@Max Köhler


Last updated: Oct 02 2023 at 04:34 UTC