How can i create an equivalent truth table in polars? Something like the below table into a truth table The efficiency of the code is important as the dataset is too large (for using it with apriori algorithm) The unstack function in polars is different, polars alterative for pd.crosstab would also work. Answer It seems like you want tot do