I want to create a simple dataframe using PySpark in a notebook on Azure Databricks. The dataframe only has 3 columns:
- TimePeriod - string
- StartTimeStanp - data-type of something like 'timestamp' or a data-type that can hold a timestamp(no date part) in the form 'HH:MM:SS:MI'*
- EndTimeStanp - data-type of something like 'timestamp' or a data-type that can hold a timestamp(no date part) in the form 'HH:MM:SS:MI'*
*hours:minutes:seconds:milliseconds, example '15:59:59:59'
Example values for one row:
TimePeriod = "00:00:00:00 -> 15:59:59:59"
StartTimeStamp = 00:00:00:00
EndTimeStamp = 15:59:59:59
Example values for secondone row:
TimePeriod = "16:00:00:00 -> 18:59:59:59"
StartTimeStamp = 16:00:00:00
EndTimeStamp = 18:59:59:59
Other rows not shown
I want the timestamp columns to be stored as a 'timestamp' with milliseconds if possible - not string. The 'TimePeriod' column is fine as a string.
I am new to PySpark and need help are writing code to construct this small dataframe. If the answer can not use a Panadas DF that would be good.