Message Boards Message Boards

0
|
4912 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

NA handling in TimeSeries["Date"] ... “0. + NA” ?

Posted 7 years ago

I have an issue with the handling of TimeSeries, which is best described by the following MWE:

data = Import["https://pastebin.com/raw/Xj6x3PSe"];
dates = Table[DateList[{StringTake[data[[k, 1]], 10], {"Day", "Month","Year"}}], {k, 2, Length[data]}];
tsdata = TimeSeries[data[[2 ;;, 2 ;;]], {dates}];
tsdata["August 26, 2008"]

The resulting output is:

{6.67345,6.55845,7.46281,7.32023,6.89391,0. +NA,0. +NA,0. +NA,0. +NA,0. +NA,0. +NA,1.82743,1.77073,1.65871,1.56591,1.52516,1.46369,0. +NA,0. +NA,0. +NA,0. +NA,0. +NA,0. +NA,0. +NA,1.47368,1.57085,1.65731,0. +NA,0. +NA,0. +NA,0. +NA,0. +NA,0. +NA,1.18979,1.02756,1.08294,1.12263,0. +NA,0. +NA,0. +NA,0. +NA,0. +NA,0. +NA,0. +NA,0. +NA,0. +NA,0. +NA,0. +NA}

However, it should be:

tsdata["Values"][[7, ;;]]

{6.67345,6.55845,7.46281,7.32023,6.89391,NA,NA,NA,NA,NA,NA,1.82743,1.77073,1.65871,1.56591,1.52516,1.46369,NA,NA,NA,NA,NA,NA,NA,1.47368,1.57085,1.65731,NA,NA,NA,NA,NA,NA,1.18979,1.02756,1.08294,1.12263,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA}

I can't figure out what causes this behaviour. Any suggestion is much appreciated.

(I'm using Mathematica 11.0.1.0)

For reference, I raised the same question on Mathematica Stackexchange.

POSTED BY: Fabian Wo

I'm sure you already solved the issue, but just in case... the raw data has 23 lines and also the length of the data after import However, you define dates for lines 2 to 23, leaving you with 22 dates. This fills wrong to me The definition of tsdata has syntax error (you probably looked at it If you want to neglect the NA parts I recommend that you read a good explanation on missing data

best

yehuda

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract