Closed simnh closed 7 years ago
Latest commit? I cannot reproduce the error. Maybe there is something wrong with the temperature file.
This is my output of self.df["temperature"]
:
2010-01-01 00:00:00 -0.2
2010-01-01 01:00:00 -0.1
2010-01-01 02:00:00 0.1
2010-01-01 03:00:00 -0.1
2010-01-01 04:00:00 -0.1
2010-01-01 05:00:00 -0.1
2010-01-01 06:00:00 0.1
...
2010-12-31 17:00:00 0.2
2010-12-31 18:00:00 0.3
2010-12-31 19:00:00 0.2
2010-12-31 20:00:00 0.0
2010-12-31 21:00:00 -0.3
2010-12-31 22:00:00 -0.4
2010-12-31 23:00:00 -0.4
Freq: H, Name: temperature, dtype: float64
I just pulled the repo, and work on the latest commit 757e15c5c796988dfba082d674016742de09dfda
Can you post the output of print(self.df["temperature"])
right before the error. Does it look similar to my output above?
The error indicates that the result of self.df["temperature"].resample('D').mean()
is not a pandas.Series but a float object. As I think resample
and mean
should work the same, I think that the temperature in your case might not be correct. Or it has something to do with your pandas installation. I tried it with 0.19 and 0.18.
I am confused by this line:
temperature = self.df["temperature"].resample('D').mean().reindex(
self.df.index).fillna(method="ffill")
The reindexing fails i guess, because mean() is called on the series, which results in a scalar, which can not be reindexed.
If the daily mean temperature is needed i guess this would make more sense (which works for me):
temperature = self.df["temperature"].resample('D', how='mean').reindex(
self.df.index).fillna(method="ffill")
If you agree I would push a hotfix for the version. But I am confused, why you cannnot reproduce the error...
According to my comment above:
Or it has something to do with your pandas installation. I tried it with 0.19 and 0.18.
As I read your suggestion to fix the bug I found out that the error is caused by a changed API of the resample method since 0.18. I could not reproduce it because I use pandas 0.18 and 0.19.
Old API (until 0.17):
resample(..., how='sum')
New API (since 0.18):
resample(...).sum()
resample(...).agg('sum')
See: http://pandas.pydata.org/pandas-docs/version/0.18.0/whatsnew.html#resample-api
I did change the requirements in the setup.py so that at least pandas 0.18 has to be installed.
Ok fixed it for me....I liked the old Api better....
The new one is more flexible, because you can even pass your own function.
Great, thanks for the first release of the demandlib. I tried to run the heat_demand example for the example directory and got the following error: