Farhang Amaji
Farhang Amaji

Reputation: 973

variable in indexing pandas dataframe problem

I can use this code

df.loc[0 :4,"strength"]

and I get pandas series with no problem. but I can't use this code

upbound  = 0
lowbound = 4
df.loc[lowbound :upbound ,"strength"]

and I get empty pandas series. so why is that? is it some sort of python version problem? I have python 3.7.6 . will the

upbound  = 0
lowbound = 4
df.ix[lowbound :upbound ,"strength"]

work?

Upvotes: 1

Views: 30

Answers (1)

BENY
BENY

Reputation: 323306

The reason here is the up and low opposite

lowbound = 0
upbound = 4
df.loc[lowbound :upbound ,"strength"]

Upvotes: 2

Related Questions