Skip to content
Advertisement

Compare list of lists with a list

I want to compare each list in the list of lists with the list based on the fact that each element is an interval and if that interval from “Listoflists” is included inside the interval from “List” we would get a True statement or else it would be a False one. And if possible, get in output a dataframe with True/False statement.

Here are the generated data :

JavaScript

Example to describe it clearly (it’s not a code it’s just to have a clear view):

JavaScript

Advertisement

Answer

For checking if each element in ListofLists is a subset of any tuple in List

JavaScript
JavaScript

This goes with the rationale that a subset of [0,1] can be [0,1] (the same set). If you want it to not include the same set, remove the = from the inequalities.


And try not to name your variables after classes (List) as it can cause unexpected errors

Advertisement