0

we have the daily predictions for the data as shown below:

df_test_daily['prediction'].head()

Datetime
2014-09-26    343.434258
2014-09-27    346.512980
2014-09-28    349.591701
2014-09-29    352.670422
2014-09-30    355.749144

We also have the mean hourly ratio (0-23 hours).


hourly_frac.head()
        Hour  ratio
0       0  0.044287
1       1  0.035343
2       2  0.029911
3       3  0.024714
4       4  0.020802

How can we use mean hourly ratio to the daily data to get hourly predictions.

say for 2014-09-26, the prediction is 343. Now the mean hourly ratio must be multiplied to 343 to generate 24 hourly data or predictions.

Expected output :

df_test_hourly['prediction']

Datetime
2014-09-26 00:00:00    X1
2014-09-26 01:00:00    X2
2014-09-26 02:00:00    X3
2014-09-26 03:00:00    X4
2014-09-26 04:00:00    X5
...
2014-09-26 23:00:00    X23
user2610
  • 35
  • 7
  • 1
    Question is not clear. Can you please put your input(s) & expected output in your question? Please post it as text & not a pictures. – moys Oct 24 '19 at 02:28
  • Upload the result of `print(df_test_daily.head())` instead. And what do you mean by _the ratio must be applied_? Multiply ratio based on `Hr` and `Hour`? If so, what would the ratio be for float `Hour` such as in your second data? – Chris Oct 24 '19 at 02:31
  • Please [provide a reproducible copy of the DataFrame with `to_clipboard`](https://stackoverflow.com/questions/52413246/provide-a-reproducible-copy-of-the-dataframe-with-to-clipboard/52413247#52413247). [Stack Overflow Discourages Screenshots](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). It is likely, the question will be downvoted, for containing unnecessary screenshots. By using screenshots, you are discouraging anyone from assisting you. No one wants to retype your stuff, from a screenshot, and screenshots are often, not readable. – Trenton McKinney Oct 24 '19 at 02:42

1 Answers1

0

You will need to merge the two dataframes to get a new dataframe with all the Datetime-Hr possible combinations with:

df_preds = df_test_daily.assign(key=1).merge(df_hours.assign(key=1)).drop('key', axis=1)

And then you can easily calculate the prediction for every hour of every day with:

df_preds['hourly_prediction'] = df_preds['prediction'] * df_preds['ratio']
Aryerez
  • 3,417
  • 2
  • 9
  • 17