Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Given the coming deprecation 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 that piece of code

like image 215
hernanavella Avatar asked Oct 29 '22 12:10

hernanavella


1 Answers

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

  1. Spend developer time on upgrading the production version of pandas to 0.19.x that is compatible with ix and expose loc ilocreplacements as you would use them now. The impact in your code is adapations for other parts of your pandas code base that will have breaking changes due to other changes in pandas 0.19 vs 0.18

  2. Install you new qualified version in production

  3. Migrate ix in your code base

  4. Deploy in production

like image 153
Zeugma Avatar answered Nov 15 '22 06:11

Zeugma