I've got a dataset at hand with a column of DateTime in String format, eg.
a = 'Tue Sep 22 1998 00:00:00 GMT+0000 (Coordinated Universal Time)'
and a is just a value from the column.
If I use Metadata Editor in Azure Machine Learning Studio, it won't work and will complain that it can't do the conversion (from String to DateTime). I guess it's something to do with the format. So I'm trying the following:
a = str(a)[:10]+','+str(a)[10:15]
#'Tue Sep 22, 1998'
Now .NET surely can do the conversion, I mean by method like Convert.ToDateTime(). However, when I visualized the output of the Python script, I found the String has been changed into 'Tue Sep 22, 1998 None,', which is quite weird. Anyone knows what's wrong with it? I'm attaching the excerpt of python code down below:
def azureml_main(dataframe1 = None, dataframe2 = None):
dataframe1['timestamp'] = dataframe1['timestamp'].apply(lambda a: str(a)[:10]+','+str(a)[10:15])
return dataframe1,
I use Python for date format normalization. You have to change to string before returning a dataFrame because underlying R will thrown an exception
def azureml_main(dataframe1 = None, dataframe2 = None):
import pandas as pd
dates = pd.to_datetime(dataframe1['DATE'])
dates = dates.apply(lambda x: x.strftime('%Y-%m-%d'))
dataframe1['DATE'] = dates
return dataframe1,
Then I use a Metadata Editor to change the type to DateTime
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With