Encoding a datetime

my data set is like that : hh:mm:ss.mmm,mV,mV
to encoder the first column I use (strptime)

from datetime import datetime as dt
record = [‘0:00.006’, ‘-0.145’,’-0.065’]
dateString = dt.strptime(record[0], "%H:%M.%S ")

but the problem that strptime don’t have the same forme:

def _strptime(data_string, format="%a %b %d %H:%M:%S %Y")

so there is two solution :slight_smile:
1 creat my datatime like the forme of my data set
2 in nupic there is other function can solve my problem

Is it possible for you to just convert the datetime string into a format that nupic uses?

How are you using nupic? If you’re using the OPF, you can just pass it a datetime object. Which part of nupic are you using where you need the string in that format? If it’s the swarming part, it can parse a multitude of different formats.

1 Like

you mean change the forme of my data set and be like this forme “%a %b %d %H:%M:%S %Y” ???

no, I just want to detect anomaly in that database and the first step in nupic is to code my data to binary code

We need to know this in order to help you. Which API are you using?

1 Like

I will use: Online Prediction Framework (OPF)

If you use the OPF, you don’t need to create an encoder, you just configure your encoders in the model params. Please follow the API Quickstart for the OPF.


sorry , I will use algorithms ,
ok , I want detect some anomaly in my data set , and my data set are in this form ( hh:mm:ss.mmm,mV,mV) .
first step, I want to encode the first column to binary form I use (dateString = dt.strptime(record[0], “%H:%M.%S) but nupic return to me a error that may data set dont have the same forme of (strptime) because the parametre of strptime are (def _strptime(data_string, format=”%a %b %d %H:%M:%S %Y")) , so my question is if there is any function can help me or I must creat my a function of datetime .
I wish you intrestand me

All you have to do is format your date strings in one of the expected date formats.

Valid date format strings are in the docs:

  • %Y-%m-%d %H:%M:%S.%f
  • %Y-%m-%d %H:%M:%S:%f
  • %Y-%m-%d %H:%M:%S
  • %Y-%m-%d %H:%M
  • %Y-%m-%d
  • %m/%d/%Y %H:%M
  • %m/%d/%y %H:%M
  • %Y-%m-%dT%H:%M:%S.%fZ
  • %Y-%m-%dT%H:%M:%SZ
  • %Y-%m-%dT%H:%M:%S