Utils Module

The utils module includes helper functions. The module currently contains a single function to help users convert numeric indexes to datetime indexes. Additional helper functions could be added at a later date.

index_to_datetime

Convert DataFrame index from int/float to datetime, rounds datetime to the nearest millisecond

mhkit.utils.index_to_datetime(index, unit='s', origin='unix')[source]

Convert DataFrame index from int/float to datetime, rounds datetime to the nearest millisecond

Parameters
  • index (pandas Index) – DataFrame index in int or float

  • unit (str (optional)) – Units of the original index

  • origin (str) – Reference date used to define the starting time. If origin = ‘unix’, the start time is ‘1970-01-01 00:00:00’ The origin can also be defined using a datetime string in a similar format (i.e. ‘2019-05-17 16:05:45’)

Returns

pandas Index – DataFrame index in datetime