def boundary_slice(df, start, stop, right_boundary=True, left_boundary=True, kind='loc'):
 result = getattr(df, kind)[start:stop]
 if (not right_boundary):
  right_index = result.index.get_slice_bound(stop, 'left', kind)
  result = result.iloc[:right_index]
 if (not left_boundary):
  left_index = result.index.get_slice_bound(start, 'right', kind)
  result = result.iloc[left_index:]
 return result

def boundary_slice ( df , start , stop , right_boundary = True , left_boundary = True , kind = 'loc' ) : result = getattr ( df , kind ) [ start : stop ] if ( not right_boundary ) : right_index = result . index . get_slice_bound ( stop , 'left' , kind ) result = result . iloc [ : right_index ] if ( not left_boundary ) : left_index = result . index . get_slice_bound ( start , 'right' , kind ) result = result . iloc [ left_index : ] return result
index slice start/stop .