In polars, how do you efficiently get the 2nd largest element, or nth for some small n compared to the size of the column?
Related Questions in PYTHON-POLARS
- Filtering inside groups in polars
- how to create a polars dataframe giving the colum-names from a list
- Polars: efficiently get the 2nd largest element
- Do repeated calls to polars with_column cause fragmenting?
- Polars asof join on next available date
- Scikit-Learn Permutating and Updating Polars DataFrame
- Parsing strings with numbers and SI prefixes in polars
- Polars apply same custom function to multiple columns in group by
- Add a column to a polars LazyFrame based on a group-by aggregation of another column
- Already pip3 installed latest version of pyarrow(15.0.2) and polars(0.20.16) but still got an error
- Replace chars in existing column names without creating new columns
- In Polars, how do you generate a column of lists, where each list is a range() defined by another column of type Int?
- Polars memory increases in Jupyter
- Read the latest S3 parquet files partitioned by date key using Polars
- Polars more concise way to replace empty list with null
Related Questions in RUST-POLARS
- How to convert dataframe with strings into ndarray on Rust
- Is it possible to pass a DataFrame created in Rust to Python?
- Rust polars scan_parquet is much slower than python when reading from s3
- How to read all columns as str with Polars on Rust?
- How can I create a new column in a dataframe by using a function in Rust (Polars)?
- Polars and Pandas DataFrame consume almost same memory. Where is the advantage of Polars?
- Combine Two Polars Dataframe in a complex way
- Best practice to use pyo3-polars with `group_by`
- returning a Vec<f32> from function costs a lot?
- Polars schema breaks with List type
- How do I cast to Categorical in Polars in Rust?
- Take every nth row on LazyFrame
- Why does a Polars dataframe appears garbled in the VSCode terminal?
- How to create a Python extension that returns back a Polars Dataframe from Rust to Python with Pyo3?
- How to (de)serialize Polars DataFrame to send it over REST call?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
You could use
top_kand slice the last row:You could also
filterwithrank, but this will perform a full sort, so it could be algorithmically less efficient:Or with numpy's
argpartition:Output:
Input:
timings:
1M rows
10M rows:
100M rows
1B rows: