How can I add a new row for a time series data preparation?

Hi there!

I’m trying to add a new row to a dataset for a time series analysis. The problem is that in some months of the year there are no records of the variable that I want to analyze in the time series, so the dataset loses the sequence in the time.

For example here:
image

March does not appear because there are no records of the variable in this month.
How can I add the monthe and a 0 that represent that there are no records of the variable in this month.?

It would be really great the help!
Thanks.

I don’t think there is a super easy way (e.g. with one or two nodes) to solve this in KNIME, but there is a small solution that should get you on the right track.

I created a similar data set, and joined it with a dataset that has all the year/months.

Example:
Data set 1:
image

Data set 2:
image

Create a key for both of them to join on (i.e. Year-Month):


(do this for both tables)

Join the two tables where the second table is the top input, and the first table is the bottom input. Join on the key you created, and make sure it’s a Left-Outer Join.
image

This is your result:

From here, you can probably use the Rule Engine node to fill in what the Year and Month should be based on the key, and use the Missing Value node to fill in the Count column with a 0.

There may be a more elegant solution to this problem, but this should at least get you started in the right direction.

2 Likes

@LilianaGarcia the same idea proposed by @Snowy. Check thisprueba.knwf (32.0 KB)

2 Likes

You could try some imputation for example with the help of an R package like Amelia

Hello @LilianaGarcia,

you can try Pivoting/Unpivoting trick. See here:

Br,
Ivan

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.