QueryBuilder#
from tmlt.analytics import QueryBuilder
- class tmlt.analytics.QueryBuilder(source_id)#
Bases:
object
High-level interface for specifying DP queries.
Each instance corresponds to applying a transformation. The full graph of QueryBuilder objects can be traversed from root to a node.
Example
>>> my_private_data.toPandas() A B X 0 0 1 0 1 1 0 1 2 1 2 1 >>> budget = PureDPBudget(float("inf")) >>> sess = Session.from_dataframe( ... privacy_budget=budget, ... source_id="my_private_data", ... dataframe=my_private_data, ... protected_change=AddOneRow(), ... ) >>> # Building a query >>> query = QueryBuilder("my_private_data").count() >>> # Answering the query with infinite privacy budget >>> answer = sess.evaluate( ... query, ... PureDPBudget(float("inf")) ... ) >>> answer.toPandas() count 0 3
Methods
Returns an average query ready to be evaluated. |
|
Creates a new column by assigning the values in a given column to bins. |
|
Returns a count query ready to be evaluated. |
|
Returns a count_distinct query ready to be evaluated. |
|
Remove rows containing infinite values. |
|
Removes rows containing null or NaN values. |
|
Enforces a |
|
Filter rows matching a condition. |
|
Applies a mapping function to each row, returning zero or more rows. |
|
Applies a transformation to each group of records sharing an ID. |
|
Returns a query that gets approximate upper and lower bounds for a column. |
|
Returns a query that gets combinations of values in the listed columns. |
|
Groups the query by the given set of keys, returning a GroupedQueryBuilder. |
|
Returns a count query containing the frequency of values in specified column. |
|
Join the table with another |
|
Joins the table with a DataFrame or a public source. |
|
Applies a mapping function to each row. |
|
Returns a quantile query requesting a maximum value, ready to be evaluated. |
|
Returns a quantile query requesting a median value, ready to be evaluated. |
|
Returns a quantile query requesting a minimum value, ready to be evaluated. |
|
Returns a quantile query ready to be evaluated. |
|
Renames one or more columns in the table. |
|
Replaces +inf and -inf values in specified columns. |
|
Replaces null and NaN values in specified columns. |
|
Selects the specified columns, dropping the others. |
|
Returns a standard deviation query ready to be evaluated. |
|
Returns a sum query ready to be evaluated. |
|
Returns a variance query ready to be evaluated. |