SortedArray¶
-
class
astropy.table.
SortedArray
(data, row_index, unique=False)[source]¶ Bases:
object
Implements a sorted array container using a list of numpy arrays.
- Parameters
- dataTable
Sorted columns of the original table
- row_indexColumn object
Row numbers corresponding to data columns
- uniquebool (defaults to False)
Whether the values of the index must be unique
Attributes Summary
Methods Summary
add
(self, key, row)Add a new entry to the sorted array.
find
(self, key)Find all rows matching the given key.
find_pos
(self, key, data[, exact])Return the index of the largest key in data greater than or equal to the given key, data pair.
items
(self)Retrieve all array items as a list of pairs of the form [(key, [row 1, row 2, …]), …]
range
(self, lower, upper, bounds)Find values in the given range.
remove
(self, key, data)Remove the given entry from the sorted array.
replace_rows
(self, row_map)Replace all rows with the values they map to in the given dictionary.
shift_left
(self, row)Decrement all row numbers greater than the input row.
shift_right
(self, row)Increment all row numbers greater than or equal to the input row.
sort
(self)Make row order align with key order.
sorted_data
(self)Return rows in sorted order.
Attributes Documentation
-
cols
¶
Methods Documentation
-
add
(self, key, row)[source]¶ Add a new entry to the sorted array.
- Parameters
- keytuple
Column values at the given row
- rowint
Row number
-
find
(self, key)[source]¶ Find all rows matching the given key.
- Parameters
- keytuple
Column values
- Returns
- matching_rowslist
List of rows matching the input key
-
find_pos
(self, key, data, exact=False)[source]¶ Return the index of the largest key in data greater than or equal to the given key, data pair.
- Parameters
- keytuple
Column key
- dataint
Row number
- exactbool
If True, return the index of the given key in data or -1 if the key is not present.
-
items
(self)[source]¶ Retrieve all array items as a list of pairs of the form [(key, [row 1, row 2, …]), …]
-
range
(self, lower, upper, bounds)[source]¶ Find values in the given range.
- Parameters
- lowertuple
Lower search bound
- uppertuple
Upper search bound
- boundstuple (x, y) of bools
Indicates whether the search should be inclusive or exclusive with respect to the endpoints. The first argument x corresponds to an inclusive lower bound, and the second argument y to an inclusive upper bound.
-
remove
(self, key, data)[source]¶ Remove the given entry from the sorted array.
- Parameters
- keytuple
Column values
- dataint
Row number
- Returns
- successfulbool
Whether the entry was successfully removed
-
replace_rows
(self, row_map)[source]¶ Replace all rows with the values they map to in the given dictionary. Any rows not present as keys in the dictionary will have their entries deleted.
- Parameters
- row_mapdict
Mapping of row numbers to new row numbers
-
shift_left
(self, row)[source]¶ Decrement all row numbers greater than the input row.
- Parameters
- rowint
Input row number