Add_datepart 'Elapsed' and time of day

Hi there, I’m wondering about datepart what the new column Elapsed contains. Glancing at the source code in structured.py didn’t help me.

What I am getting at is: I would like to include time of day (hours and minutes) as part as my dataset. I’m working with the number of parked cars in a group of public parking garages, and I have new data points every 5 minutes. My reason is that the time of day is important for estimating y (number of parked cars).

Should I manually create the columns Hourofday [0…23] and MinuteofHour[0…59] ?

Update
I figured out that Elapsed is the UNIX timestamp.
So 1438300800 translates to GMT: Friday, July 31, 2015 12:00:00 AM
Just duckduckgo unix timestamp converter

No…
Just modify that version…
Create a copy of that function in the same file with another name and just change it a bit…

Given a dataframe with column ‘date’

(0   2018-03-06 13:25:01
 1   2018-03-06 12:35:01
 2   2018-03-06 12:35:01
 Name: date, dtype: datetime64[ns], pandas.core.series.Series)

I solved my problem with:

dfCats[‘Hourofday’] = dfCats.apply(lambda row: row[‘date’].to_pydatetime().hour , axis=1)
dfCats[‘Minutesofhour’] = dfCats.apply(lambda row: row[‘date’].to_pydatetime().minute , axis=1)

Now I have two new columns named Hourofday and Minutesofhour, slice:

dfCats[‘Hourofday’][0:3], dfCats[‘Minutesofhour’][0:3]

(0 13
1 12
2 12
Name: Hourofday, dtype: int64,
0 25
1 35
2 35
Name: Minutesofhour, dtype: int64)

1 Like