rnalysis.filtering.FoldChangeFilter.sortο
- FoldChangeFilter.sort(by: str | List[str], ascending: bool | List[bool] = True, na_position: str = 'last', inplace: bool = True)ο
Sort the rows by the values of specified column or columns.
- Parameters:
by (str or list of str) β Names of the column or columns to sort by.
ascending (bool or list of bool (default=True)) β Sort ascending vs. descending. Specify list for multiple sort orders. If this is a list of bools, it must have the same length as βbyβ.
na_position ('first' or 'last', default 'last') β If βfirstβ, puts NaNs at the beginning; if βlastβ, puts NaNs at the end.
inplace (bool (default=True)) β If True, perform operation in-place. Otherwise, returns a sorted copy of the Filter object without modifying the original.
- Returns:
None if inplace=True, a sorted Filter object otherwise.
- Examples:
>>> from rnalysis import filtering >>> counts = filtering.Filter('tests/test_files/counted.csv') >>> counts.head() cond1 cond2 cond3 cond4 WBGene00007063 633 451 365 388 WBGene00007064 60 57 20 23 WBGene00044951 0 0 0 1 WBGene00007066 55 266 46 39 WBGene00007067 15 13 1 0 >>> counts.sort(by='cond1',ascending=True) >>> counts.head() cond1 cond2 cond3 cond4 WBGene00044951 0 0 0 1 WBGene00077504 0 0 0 0 WBGene00007069 0 2 1 0 WBGene00077502 0 0 0 0 WBGene00077503 1 4 2 0