How to replace df.ix with df.loc or df.iloc?

Given the outgoing deviation of df.ix [...]

How can I replace .ix in this piece of code?

df_1 = df.ix[:, :datetime.time(16, 50)] df_2 = df.ix[:, datetime.time(17, 0) : ] df_3 = df2.shift(periods = 1) df_4 = pd.concat([df3, df1], axis = 1) 

For reference, this is some background on this piece of code

+5
source share
1 answer

Replacing ix in your code base is a four-step process as follows:

  • Take the developer's time to upgrade the production version of pandas to 0.19.x, which is compatible with ix and exposes replacements for loc iloc , as you now use them. The effect in your code is an adaptation for other parts of your pandas code base, which will have changes in the change due to other changes in pandas 0.19 versus 0.18

  • Install a new qualified version on production

  • Move ix to code base

  • Production Deployment

+2
source

Source: https://habr.com/ru/post/1263787/


All Articles