lundi 18 juillet 2016

Convert a list of values to a time series in python

I want to convert the foll. data:

jan_1   jan_15  feb_1   feb_15  mar_1   mar_15  apr_1   apr_15  may_1   may_15  jun_1   jun_15  jul_1   jul_15  aug_1   aug_15  sep_1   sep_15  oct_1   oct_15  nov_1   nov_15  dec_1   dec_15
0       0       0       0       0       1       1       2       2       2       2       2       2        3      3       3       3       3       0       0       0       0       0       0

into a array of length 365, where each element is repeated till the next date days e.g. 0 is repeated from january 1 to january 15...

I could do something like numpy.repeat, but that is not date aware, so would not take into account that less than 15 days happen between feb_15 and mar_1.

Any pythonic solution for this?

Aucun commentaire:

Enregistrer un commentaire