How To Select Range In Pandas Using A Row
I have a Pandas dataframe. I have in another process selected a row from that dataframe. At another method, I now need to select a range from that dataframe where the row is and go
Solution 1:
This should do it
integer_location = np.where(df.index == 3454)[0][0]
start = max(0, integer_location - 55)
end = max(1, integer_location)
dfRange = df.iloc[start:end]
This link has more info Getting the integer index of a Pandas DataFrame row fulfilling a condition?
Post a Comment for "How To Select Range In Pandas Using A Row"