In the foll. dataframe, I have a collection of year and month values as tuples in a list:
state
alabama [(2017.0, 10.0), (2017.0, 11.0), (2017.0, 12.0), (2018.0, 1.0)]
arkansas [(2017.0, 10.0), (2017.0, 11.0), (2017.0, 12.0)]
colorado [(2017.0, 9.0), (2017.0, 10.0), (2017.0, 11.0)]
How can I extract a superset list of year and month combinations? In this case, the soln would be:
[(2017.0, 9.0), (2017.0, 10.0), (2017.0, 11.0), (2017.0, 12.0), (2018.0, 1.0)]
I could potentially do it using a for loop but that would be slow, anything more pythonic?
Here is what I tried:
for row in df:
if all(y in row for x, y in df):
tmp = row
but I get this error:
ValueError: too many values to unpack (expected 2)