code: def as_dict(df, ix=':'):
      
      if isinstance(df.index, pd.DatetimeIndex):
          df['datetime'] = df.index
      return df.to_dict(orient='records')[ix]
docs: converts df to dict and adds a datetime field if df is datetime