opengridcc / opengrid-dev

Open source building monitoring, analysis and control
Apache License 2.0
26 stars 21 forks source link

Adapt code for pandas 0.18 #127

Closed JrtPec closed 7 years ago

JrtPec commented 8 years ago

@saroele I believe we should move forward with this, tmpo is giving me IndexErrors on pandas 0.17 which I don't get on pandas 0.18... @icarus75 I sent you an e-mail on this a couple of weeks ago, thinking it was an issue with tmpo-blocks, but it looks like it is a bug with pandas 0.17

JrtPec commented 8 years ago

@kdebrab I remember when you told us exactly why and how upgrading to pandas 0.18 would cause problems... would you mind refreshing my memory?

kdebrab commented 8 years ago

The main cause of problems when upgrading to 0.18 are changes in .resample(). The quick solution is to make sure the optional (but deprecated) parameter how is always specified (in other words, make sure to include how='mean' whenever it is missing). Then everything will work as before, apart from the FutureWarnings you get.

In order to avoid also the FutureWarnings one can do:

from distutils.version import StrictVersion
if StrictVersion(pd.__version__) >= '0.18.0':
    df2 = df1.resample(rule).mean()
else:
    df2 = df1.resample(rule, how='mean')

Note that .resample(rule).mean() returns different results in 0.18.0 compared to previous versions!

JrtPec commented 8 years ago

Yesterday, I heard somebody ( @saroele ) say (I'm paraphrasing): "I'm not adapting to Pandas 0.18, I'll go straight for 0.19" ... which was released 3 days ago: http://pandas.pydata.org

saroele commented 8 years ago

I should have said that I'll go straight to 1.0, that would have saved my ass for a couple years... :-) ok, good point to shift to 0.19.

On Wed, Oct 5, 2016 at 6:05 PM, Jan Pecinovsky notifications@github.com wrote:

Yesterday, I heard somebody ( @saroele https://github.com/saroele ) say (I'm paraphrasing): "I'm not adapting to Pandas 0.18, I'll go straight for 0.19" ... which was released 3 days ago: http://pandas.pydata.org

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/opengridcc/opengrid/issues/127#issuecomment-251719743, or mute the thread https://github.com/notifications/unsubscribe-auth/AAiVBmb99O0mA3vIlVMAvq2y2_Rgiih6ks5qw8q8gaJpZM4IK6oj .