Converting sensor tag data in DSX

106 views Asked by At

I'm working on converting the existing recipe for Data Science Experience (DSX) to use data from a connected Sensor Tag device. However the mobile applications for that device send the data as strings rather than numerics - this is causing the DSX recipe that calculates a Z score to choke. The data is coming from a cloudant db used as a histtorian for Watson IoT Platform so I cant simply reformat it there. Is there a simple way to convert the data inside a DSX notebook ?

2

There are 2 answers

1
idan On

I'm not familiar with DSX but you can use node red to parse the information from devices then store it in cloudant db in numeric format

2
Romeo Kienzler On

Just access the row object and convert it:

cloudantdata.rdd.map(lambda row : float(row.temperature)).take(10)

EDIT 30.1.17:

To directly address your question:

df = cloudantdata.selectExpr("timestamp as timestamp", "data.d.objectTemp as temperature").map(lambda row : (row.timestamp,float(row.temperature)))

That way you get a tuple RDD which IMHO anyway is more usable as a RowRDD