Skip to content

Instantly share code, notes, and snippets.

@xoelop
Created January 23, 2020 10:34
Show Gist options
  • Save xoelop/dc7d5f923cbf156dcb157219320272e8 to your computer and use it in GitHub Desktop.
Save xoelop/dc7d5f923cbf156dcb157219320272e8 to your computer and use it in GitHub Desktop.
import pandas as pd
data = pd.Series([1, 4, 4, 6, 2, 4, 7, 4, 7])
# data can be a series or a dataframe
# this calculates the inverse quantile for each value of data
inverse_quantiles = data.apply(lambda x: ((data <= x).sum()) / len(data))
# read more: https://stackoverflow.com/a/58186830/5031446
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment