Reputation: 11
when I excute
basic_data.loc[2:61, 'v_00']
it return
Series([], Name: v_00, dtype: float64)
Why?
I wonder why I got empty series.
Upvotes: 0
Views: 55
Reputation: 262634
2:61
will slice the rows (by position) that are between the row index 2 and the row index 61, which are none. It will not consider the values between the integer 2 and 61.
I believe you want between
:
basic_data.loc[basic_data.index.to_series().between(2, 61), 'v_00']
# or
basic_data.loc[(basic_data.index >= 2) & (basic_data.index <= 61), 'v_00']
Or first sort your index:
basic_data = basic_data.sort_index()
basic_data.loc[2:61, 'v_00']
Upvotes: 2