sensortoolkit.datetime_utils._set_datetime_index.set_datetime_index
- set_datetime_index(df, idx_fmt=None)[source]
Set the
DateTime
timestamp column as the index.- Parameters
df (pandas DataFrame) – Sensor DataFrame for which the index is being assigned.
idx_fmt (str) – The formatting for the timestamp index. If none, date/time format will be inferred (slower). Explicitly specifying the format speeds up index assignment as
pandas.to_datetime()
doesn’t have to search for the appropriate formatting.
- Returns
Modified sensor DataFrame with the index assigned as the
DateTime
column.- Return type
df (pandas DataFrame)
- Raises
NameError – If the column header
DateTime
is not found in the DataFrame (may occur if the user assigns a label other thanDateTime
to the time-like index during the process of data ingestion.)